<!-- eslint-disable max-lines -->
<template>
  <div class="witness-body Workbench">
    <!-- 管理员登录显示的面包屑 -->
    <breadcrumb
      v-if="managerFlag"
      :bread-path-list="breadPathList"
      last-bread-title="查看见证中任务"
      :show-back-btn-flag="true"
      @handleBack="handleBackFn"
    />
    <!-- 见证员登录显示的面包屑 -->
    <breadcrumb v-else />
    <!-- {{ currProjectData.witnessSubTaskStatusEnum }} -->
    <!-- 页面开始 -->
    <div class="witness-main">
      <div class="k-header-box">
        <!-- 管理员 start -->
        <div v-if="managerFlag" class="layout-between">
          <h2 class="k-manager-header">
            <!-- {{ currProjectData.witnessSubTaskName }}-->
            <!-- {{ currProjectData.witnessSubTaskStatusEnum }} -->
            <!-- <span>当前任务:</span> -->
            <span class="task-status" v-if="currProjectData.witnessSubTaskName">
              <span :class="[currProjectData.witnessSubTaskStatusEnum]">
                {{
                  currProjectData.witnessSubTaskName.indexOf("复评") > -1 ? "评" : currProjectData.witnessSubTaskName
                }}
              </span>
              <i
                :class="{
                  danger: currProjectData.isWarn
                }"
              >
                <em class="icon-yujing" />
              </i>
            </span>
            <div class="" style="min-width: 780px">
              <div class="project-title">
                <span
                  class="short-title"
                  :title="
                    currProjectData.projectName +
                    (currProjectData.bidSectionName ? ' - ' : '') +
                    currProjectData.bidSectionName
                  "
                >
                  <b>{{ currProjectData.projectName }}</b>
                  <b v-if="currProjectData.bidSectionName">- {{ currProjectData.bidSectionName }}</b>
                </span>
              </div>
              <div class="k-info">
                <span class="item">
                  <i class="icon-shenfen1" />
                  见证人：{{ currProjectData.witnessUserName }}
                </span>
                <span class="item">
                  <i class="icon-time" />
                  见证开始时间：{{ currProjectData.witnessStartTime }}
                </span>
                <!-- BTN_STOP_WITNESS_RECORD  -->
                <span
                  v-if="
                    $hasBtnsPerm('BTN_STOP_WITNESS_RECORD') &&
                    (subtaskTimeDiffStopTotle > 1 || currProjectData.witnessSubTaskStatusEnum === 'WITNESS_STOP')
                  "
                  class="ui-pr15"
                >
                  <el-button type="text" @click="stopRecordBtnFn('read')">暂停记录</el-button>
                </span>
                <i class="icon-shaixuantiaojian1" />
                <span>
                  <g-timer
                    v-if="subtaskTimeDiffTotle && currProjectData && currProjectData.witnessStartTime"
                    :type="currProjectData.witnessSubTaskStatusEnum !== 'WITNESS_STOP'"
                    size="small"
                    :subtask-time-diff-totle="subtaskTimeDiffTotle"
                    :start-time="currProjectData.witnessStartTime"
                    :end-time="currProjectData.witnessEndTime"
                  />
                </span>
              </div>
            </div>
          </h2>
          <!--  -->
          <template
            v-if="
              TASKOBJ.videoWitnessLinkCodeConfig &&
              TASKOBJ.videoWitnessLinkCodeConfig.indexOf(currProjectData.witnessLinkCode) > -1
            "
          >
            <el-button
              v-if="$hasBtnsPerm('BTN_VIEW_WITNESS_VIDEO')"
              type="primary"
              size="default"
              icon="icon-chakanshipin1"
              @click="openMediaFn('gly')"
            >
              查看视频
            </el-button>
          </template>
        </div>
        <!-- 管理员 end -->
        <!-- 见证人员 start -->
        <div v-if="!managerFlag">
          <div class="la yout-between" style="min-height: 37px">
            <div class="">
              <!-- {{ topTaskYujingData }} -->
              <!--{{ topTaskAllData }} -->
              <!-- {{ topTaskActive }} -->
              <!--  -->
              <el-tabs v-model="topTaskActive" @tab-click="stepsClickFn">
                <template v-for="item in this.TASKOBJ.taskWitnessLinkAll">
                  <el-tab-pane
                    :name="item.value"
                    :key="item.value + item.label"
                    v-if="topTaskAllData[item.value] && topTaskAllData[item.value].length"
                  >
                    <span slot="label">
                      {{ item.label }}({{ topTaskAllData[item.value].length }}个)
                      <i
                        v-if="topTaskYujingData[item.value] && topTaskYujingData[item.value].isWarn"
                        class="icon-yujing2 font-danger"
                      />
                    </span>
                  </el-tab-pane>
                </template>
              </el-tabs>
            </div>
            <div class="add-task-btn">
              <el-button
                v-if="$hasBtnsPerm('BTN_ADD_WITNESS_SUB_TASK')"
                type="primary"
                plain
                size="mini"
                icon="el-icon-circle-plus-outline"
                @click="addTaskFn"
              >
                加入任务
              </el-button>
            </div>
          </div>
          <div class="top-box">
            <div ref="topTaskList---" class="top-task-box">
              <!--  v-show="leftRightBtnFlag" -->
              <el-button
                :class="{ 'visible-hide': !leftRightBtnFlag }"
                type="text"
                size="default"
                icon="el-icon-arrow-left"
                @click="taskLeftFn"
              />

              <div class="witness-collapse" ref="refTaskList"  id="witnessCollapseBody">
                <div class="witness-collapse-body">
                  <template v-for="(item, index) in processedData.datalist">
                    <!--项目-->
                    <div
                      v-if="item.type === 'PRODUCT' && (!item.isSelectProduct || (item.isSelectProduct && !processedData.isShowTaskAll))"
                      class="product-item"
                      :class="{
                        'product-item-ok': item.isSelectProduct,
                        'product-item_stop':item.witnessSubTaskStatusEnum === 'WITNESS_STOP'
                      }"
                      @click="anProductDefaultFirstTask(item.pn, item.isOneTask)"
                    >
                      <div class="product-item-card">
                        <div>
                          <el-popover
                            title="项目名称"
                            placement="top-start"
                            width="200"
                            trigger="hover"
                            :content="item.projectName">
                            <div slot="reference" class="product-item-card-popover">项目：{{ item.projectName }}</div>
                          </el-popover>

                          <div v-if="topTaskActive === 'KB' || topTaskActive === 'PB'">
                            开标室：{{item.openAddress}}
                            <span style="margin-left: 20px">评标室：{{item.evaluationAddress}}</span>
                          </div>

                          <div class="text2" v-else>
                            标室：{{ item.address }}
                          </div>

                          <div class="text2">
                            {{topTaskActiveLabel}}时间：{{  item.startTime}}
                          </div>
                        </div>
                      </div>
                      <el-tooltip
                        v-if="!item.isOneTask"
                        class="item"
                        effect="dark"
                        content="展开项目"
                        placement="top">
                        <div class="product-item-card-an el-icon-arrow-right"/>
                      </el-tooltip>
                    </div>



                    <!--标段-->
                    <div
                      v-show="processedData.isShowTaskAll"
                      v-if="item.type === 'TASK'"
                      :class="{
                        'product-item_stop':item.witnessSubTaskStatusEnum === 'WITNESS_STOP'
                      }"
                    >
                      <div

                        @click="selectTaskByIndex(index, item.tn, item._taskIndex)"
                        class="task-item"
                        :class="{
          'task-item-first':item.isFirst,
          'task-item-last':item.isLast,
          'task-item-ok': item.isSelectTask,

      }"
                      >
                        <el-popover
                          title="项目名称"
                          placement="top-start"
                          width="200"
                          trigger="hover"
                          :content="item.projectName">
                          <div  slot="reference" class="task-item-text">项目：{{ item.projectName }}</div>
                        </el-popover>



                        <el-popover
                          title="标段名称"
                          placement="top-start"
                          width="200"
                          trigger="hover"
                          :content="item.bidSectionName">
                          <div slot="reference" class="task-item-text">标段：{{ item.bidSectionName }}</div>
                        </el-popover>

                        <el-tooltip class="item" effect="dark" content="收起项目" placement="top">
                          <div
                            @click.capturn.stop="hiddenTaskAll()"
                            class="task-item-lest-button el-icon-arrow-left">
                          </div>
                        </el-tooltip>
                      </div>
                    </div>

                  </template>
                </div>
              </div>

<!--              <ul ref="refTaskList" :class="{ 'task-list': true, topTaskVisible: !topTaskVisible }">-->
<!--                <li-->
<!--                  v-for="(item, index) in topTaskData"-->
<!--                  :key="item.witnessSubTaskId"-->
<!--                  :class="[item.active]"-->
<!--                  @click="projectClickFn(item, index)"-->
<!--                >-->
<!--                  <div class="info">-->
<!--                    <div class="text1">-->
<!--                      <em>项目：</em>-->
<!--                      <span :title="item.projectName">{{ item.projectName }}</span>-->
<!--                    </div>-->
<!--                    <div v-if="item.bidSectionName" class="text2">-->
<!--                      <em>标段：</em>-->
<!--                      <span :title="item.bidSectionName">{{ item.bidSectionName }}</span>-->
<!--                    </div>-->
<!--                  </div>-->
<!--                  &lt;!&ndash; && item.witnessSubTaskId != id) &ndash;&gt;-->
<!--                  <div v-if="item.isWarn || item.danger" class="check">-->
<!--                    <i class="icon-yujing1" />-->
<!--                  </div>-->
<!--                  &lt;!&ndash; <div class="check"><i class="el-icon-check"></i></div> &ndash;&gt;-->
<!--                </li>-->
<!--              </ul>-->
              <!--
          v-show="leftRightBtnFlag" -->
              <el-button
                :class="{ 'visible-hide': !leftRightBtnFlag }"
                type="text"
                size="default"
                icon="el-icon-arrow-right"
                @click="taskRightFn"
              />
            </div>
            <!-- <div class="ui-pt10">
          <el-button
            v-if="topTaskData.length"
            type="text"
            size="default"
            @click="topTaskVisible = !topTaskVisible"
            >{{ !topTaskVisible ? "收起" : "展开" }}
            <i
              :class="[
                topTaskVisible ? 'el-icon-arrow-down' : 'el-icon-arrow-up',
              ]"
            ></i>
          </el-button>
        </div> -->
          </div>
        </div>
        <!-- 见证人员 end -->
      </div>
      <div class="layout-wrapper">
        <div class="layout-wrapper layout-row">
          <div v-if="ruleForm.witnessMode != 'ARTIFICIAL'" :class="['main-side', sideFold ? 'sideFold' : '']">
            <div class="side-content">
              <div class="side-tabs">
                <el-tabs v-model="sideRecordActive" @tab-click="handleClick">
                  <el-tab-pane
                    :disabled="!(currProjectData && currProjectData.witnessStartTime)"
                    label="交易数据"
                    name="first"
                  />
                  <el-tab-pane
                    :disabled="!(currProjectData && currProjectData.witnessStartTime)"
                    label="预警信息"
                    name="second"
                  />
                </el-tabs>
              </div>
              <!-- {{ activities }} v-if="sideRecordActive === 'first'"-->
              <div class="timeline-box">
                <div class="timeline-box-content">
                  <el-result
                    v-if="activitiesNoDataFlag && !activities.length"
                    icon="empty1"
                    title="暂无数据"
                    :size="180"
                  />
                  <el-scrollbar
                    v-else
                    ref="right"
                    tag="ul"
                    wrap-class="demo-scrollbar-list"
                    wrap-style="color: red;"
                    view-style="font-weight: bold;"
                    view-class="view-box"
                    :noresize="true"
                  >
                    <li class="infinite-list-item">
                      <!-- {{ 1111111 }} -->
                      <el-timeline class="" :reverse="reverse">
                        <el-timeline-item
                          v-for="(item, index) in activities"
                          :key="index"
                          :type="warningLevelFn(item.warningLevel, 'EXCEPTION_TYPE')"
                        >
                          <div class="timeline-content">
                            <span v-if="className === item.parentItemCode" :id="item.parentItemCode">
                              <span class="blue">{{ item.itemName }}</span>
                            </span>
                            <span v-else :id="item.parentItemCode" class="ui-mt">{{ item.itemName }}</span>
                            <span :id="item.parentItemCode" class="timeline-tag">{{ item.systemName }}</span>
                            <div
                              v-for="(jtem, jndex) in item.witnessTradeAndWarnDetailInfoList"
                              :key="jndex"
                              :class="witnessStatusFn(jtem.warningLevel, jtem.witnessStatus)"
                            >
                              <template v-if="jtem.witnessInfoContent">
                                <div v-for="(ttem, k) in jtem.witnessInfoContent.split('<br/>')" :key="k">
                                  {{ ttem }}
                                </div>
                                <div>
                                  {{ jtem.witnessStatus == "EXCEPTION" ? "状态异常" : "状态正常" }}
                                </div>
                              </template>
                            </div>
                          </div>
                        </el-timeline-item>
                      </el-timeline>
                    </li>
                  </el-scrollbar>
                </div>
                <!-- 分页 -->
              </div>
              <div v-if="!sideFold" class="layout-footer ui-pt10">
                <!-- {{ pageObj.total + " " + pageObj.pageSize }} -->
                <div v-if="sideRecordActive === 'first'" class="fenye">
                  <pagination
                    v-if="pageQueryList.total > pageQueryList.pageSizes[0] && this.pageQueryList.pageSize != -1"
                    :total="pageQueryList.total"
                    :page.sync="pageQueryList.currentPage"
                    :limit.sync="pageQueryList.pageSize"
                    :page-sizes="pageQueryList.pageSizes"
                    layout="total,prev,pager, next"
                    :pager-count="5"
                    @pagination="infoRecordQuerylistFn"
                  />
                </div>
                <div v-else class="fenye">
                  <pagination
                    v-if="pageQueryList.total > pageQueryList.pageSizes[0] && pageQueryList.pageSize != -1"
                    :total="pageQueryList.total"
                    :page.sync="pageQueryList.currentPage"
                    :limit.sync="pageQueryList.pageSize"
                    :page-sizes="pageQueryList.pageSizes"
                    layout="total,prev,pager, next"
                    :pager-count="5"
                    @pagination="warnRecordQuerylistFn"
                  />
                </div>
              </div>
            </div>
            <div class="fold-btn" @click="sideFold = !sideFold">
              <i :class="sideFold ? 'el-icon-arrow-right' : 'el-icon-arrow-left'" />
            </div>
          </div>
          <div class="layout-wrapper layout-body">
            <!-- 见证管理员不显示 -->
            <!-- {{ $route.path === "/Workbench" }} -->
            <div v-if="!managerFlag" class="layout-between header-btn-box ui-mt10">
              <div v-if="currProjectData && currProjectData.witnessStartTime" class="button-list">
                <el-button type="primary" size="default" icon="el-icon-circle-plus-outline" @click="addMattersClick">
                  新增事项
                </el-button>
                <template
                  v-if="
                    TASKOBJ.videoWitnessLinkCodeConfig &&
                    TASKOBJ.videoWitnessLinkCodeConfig.indexOf(currProjectData.witnessLinkCode) > -1
                  "
                >
                  <el-button
                    v-if="$hasBtnsPerm('BTN_VIEW_WITNESS_VIDEO')"
                    type="primary"
                    size="default"
                    icon="icon-chakanshipin1"
                    @click="openMediaFn"
                  >
                    查看视频
                  </el-button>
                </template>
                <!-- witnessSubTaskStatusEnum WITNESSING   BTN_WITNESS_STOP-->
                <el-button
                  v-if="$hasBtnsPerm('BTN_WITNESS_STOP') && currProjectData.witnessSubTaskStatusEnum === 'WITNESSING'"
                  icon="icon-zantingjianzheng"
                  @click="subtaskPauseClick"
                >
                  暂停见证
                </el-button>
                <el-tooltip
                  class="item"
                  v-else-if="
                    $hasBtnsPerm('BTN_WITNESS_RECOVERY') && currProjectData.witnessSubTaskStatusEnum === 'WITNESS_STOP'
                  "
                  effect="dark"
                  content="见证已暂停，点击恢复后可继续见证"
                  placement="top-start"
                >
                  <el-button icon="icon-huifujianzheng" @click="subtaskRecoverClick">恢复见证</el-button>
                </el-tooltip>

                <template v-if="$hasBtnsPerm('BTN_FINISH_WITNESS_SUB_TASK')">
                  <el-button
                    v-if="topTaskActive !== 'PB'"
                    icon="icon-jieshujianzheng1"
                    @click="finishWitnessFn"
                  >
                    结束见证
                  </el-button>
                  <template v-else>
                    <gzOverWitness @over="subtaskFinishFn('PB')" :id="this.id"/>
                    <gzAddReviewTime :id="this.id"/>
                  </template>
                </template>
                <el-button
                  v-if="$hasBtnsPerm('BTN_TRANSFER_WITNESS_SUB_TASK')"
                  icon="icon-yijiaojianzheng"
                  @click="subtaskClick"
                >
                  移交见证
                </el-button>
              </div>
              <!-- {{ currProjectData.witnessSubTaskStatusEnum }}
              {{ subtaskTimeDiffTotle }} -->
              <div
                class="layout-time"
                v-if="subtaskTimeDiffTotle && currProjectData && currProjectData.witnessStartTime"
              >
                <!-- 判断条件显示，没有暂停过的不显示 by link
                subtaskTimeDiffTotle 有值代表恢复过
                currProjectData.witnessSubTaskStatusEnum === 'WITNESS_STOP' 暂停中
                 -->
                <template
                  v-if="
                    $hasBtnsPerm('BTN_STOP_WITNESS_RECORD') &&
                    (subtaskTimeDiffStopTotle > 1 || currProjectData.witnessSubTaskStatusEnum === 'WITNESS_STOP')
                  "
                >
                  <el-button type="text" @click="stopRecordBtnFn('edit')">暂停记录</el-button>
                  <div class="interval-line"></div>
                </template>
                <!-- 已见证时长: -->
                <!-- {{ subtaskTimeDiffTotle }} -->
                <g-timer
                  :key="currProjectData.witnessStartTime"
                  v-if="subtaskTimeDiffTotle && currProjectData && currProjectData.witnessStartTime"
                  :type="currProjectData.witnessSubTaskStatusEnum !== 'WITNESS_STOP'"
                  :subtask-time-diff-totle="subtaskTimeDiffTotle"
                  :start-time="currProjectData.witnessStartTime"
                  :end-time="currProjectData.witnessEndTime"
                />
              </div>
            </div>
            <!-- 见证记录 开始 disabled-->
            <div class="ui-title ui-mt10">见证记录</div>
            <div class="layout-between" style="margin-top: -36px">
              <span>
                <!-- <el-button
              type="primary"
              v-if="
                $hasBtnsPerm('BTN_CONFIRM_WITNESS_RECORD') &&
                  currProjectData.projectName
              "
              size="default"
              @click="allSubmitFn"
              icon="icon-quanbuqueren1"
              >全部确认</el-button
            > -->
              </span>
              <!-- 搜索 见证事项 -->
              <el-input
                v-model.trim="matterKeyWord"
                placeholder="事项说明/见证记录"
                @keyup.enter.native="matterKeyWordFn"
                class="ui-w300"
              >
                <el-button slot="append" type="primary" icon="el-icon-search" @click="matterKeyWordFn" />
              </el-input>
            </div>
            <div class="record-box">
              <!-- 列表 -->
              <div class="record-list ui-mt10">
                <div class="table-box">
                  <el-table :data="recordData" isdrag>
                    <el-table-column type="index" align="center" :index="indexFn" label="序号" width="50">
                      <template slot-scope="scope">
                        {{ (pageObj.currentPage - 1) * pageObj.pageSize + scope.$index + 1 }}
                      </template>
                    </el-table-column>
                    <el-table-column prop="data.recordSortStr" label="编号" align="left" width="60" />
                    <!-- <el-table-column
                  prop="data.parentItemName"
                  label="见证事项"
                  min-width="200"
                >
                </el-table-column> -->
                    <!-- show-overflow-tooltip -->
                    <el-table-column prop="data.itemName" label="事项说明" min-width="200">
                      <template slot-scope="scope" row-click>
                        <div v-if="!scope.row.edit">
                          <el-button type="text" size="default" @click="associatedClickFn(scope)">
                            {{ scope.row.data.itemName }}
                          </el-button>
                        </div>
                        <div v-else>
                          <!-- {{ scope.row.data.itemCodes }} -->
                          <el-cascader
                            v-model="scope.row.data.itemCodes"
                            style="width: 100%"
                            option-max-width="300px"
                            :props="{ multiple: false }"
                            :options="scope.row.matterInstruction"
                            @change="rowItemCodeChangeFn"
                          />
                        </div>
                      </template>
                    </el-table-column>
                    <el-table-column prop="data.itemStatus" label="状态" header-align="left" width="100">
                      <template slot-scope="scope">
                        <!-- {{ scope.row.data.warningLevel }} -->
                        <div v-if="!scope.row.edit">
                          <!-- {{ scope.row.data.itemStatus }} -->
                          <!-- 这里报错先注释，影响测试 -->
                          <!-- <el-tag
                            :type="scope.row.data.itemStatus == 'EXCEPTION_TYPE' ? 'danger' : ''"
                            :color="buildRecordStatusFn(scope.row.data.warningLevel, 'color')"
                            :bg-color="buildRecordStatusFn(scope.row.data.warningLevel, 'bg-color')"
                            :border-color="buildRecordStatusFn(scope.row.data.warningLevel, 'border-color')"
                          > -->
                          <el-tag
                            :class="['level-tag', scope.row.data.warningLevel]"
                            :type="warningLevelFn(scope.row.data.warningLevel, scope.row.data.itemStatus)"
                          >
                            {{ witnessItemStatusFn(scope.row.data.itemStatus) }}
                          </el-tag>
                        </div>
                        <div v-else>
                          <!-- <el-select
                            v-model="scope.row.data.itemStatus"
                            value-key=""
                            placeholder=""
                            option-max-width="300px"
                            @change="rowStartusChangeFn(scope)"
                          >
                            <el-option
                              v-for="item in TASKOBJ.witnessItemStatus"
                              :key="item.value"
                              :label="item.label"
                              :value="item.value"
                            />
                          </el-select> -->
                        </div>
                      </template>
                    </el-table-column>
                    <!-- show-overflow-tooltip -->
                    <el-table-column prop="data.witnessRecordDesc" label="见证记录" min-width="165">
                      <template v-if="scope.row.data.witnessRecordDesc" slot-scope="scope">
                        <template v-for="(item, index) in scope.row.data.witnessRecordDesc.split('<br/>')">
                          <div :key="index">{{ index === 0 ? scope.row.data.occurrentTime : "" }} {{ item }} </div>
                        </template>
                        <!-- <div v-else>
                        <el-input
                          v-model.trim="scope.row.data.witnessRecordDesc"
                          placeholder=""
                          size="normal"
                        />
                      </div> -->
                      </template>
                    </el-table-column>
                    <!--  show-overflow-tooltip -->
                    <el-table-column prop="data.source" label="记录来源" min-width="100" />
                    <!--  show-overflow-tooltip -->
                    <el-table-column prop="data.witnessRecordTime" label="时间" min-width="108" />
                    <!-- <el-table-column prop="data.source" label="记录人" width="80">
                  </el-table-column> -->
                    <el-table-column prop="data.confirmUserName" label="确认人" width="80" />
                    <el-table-column v-if="!managerFlag" label="操作" width="110">
                      <template slot-scope="scope">
                        <!-- OPERATE_WITNESS_RECORD_EDIT 编辑见证记录
OPERATE_WITNESS_RECORD_DELETE 删除见证记录
OPERATE_WITNESS_RECORD_SUBMIT 提交见证记录
OPERATE_WITNESS_RECORD_CHECK 复核见证记录 -->
                        <!-- v-if="scope.row.type === 'start'" -->
                        <!-- {{ scope.row.data.witnessScene }} -->
                        <!-- {{ scope.row.edit }}111 -->
                        <template v-if="!!scope.row.edit">
                          <el-button type="text" size="default" @click="saveRecordClickFn(scope)">保存</el-button>
                          <el-button type="text" size="default" @click="cancelRecordClickFn(scope)">取消</el-button>
                        </template>
                        <div v-else>
                          <template v-for="item in scope.row.pageOpers">
                            <!-- :disabled="
                                scope.row.data.witnessScene === 'STOP' || scope.row.data.witnessScene === 'RECOVER'
                              " -->
                            <el-button
                              v-if="item.code === 'OPERATE_WITNESS_RECORD_EDIT'"
                              :key="item.code"
                              type="text"
                              size="default"
                              @click="editRecordClickFn(scope)"
                            >
                              编辑
                            </el-button>
                            <el-button
                              v-if="item.code === 'OPERATE_WITNESS_RECORD_SUBMIT'"
                              :key="item.code + 'submit'"
                              :disabled="item.disabled"
                              type="text"
                              size="default"
                              @click="submitRecordClickFn(scope)"
                            >
                              确认
                            </el-button>
                            <!-- {{ item.disabled }} -->
                            <el-button
                              v-if="item.code === 'OPERATE_WITNESS_RECORD_CHECK'"
                              :key="item.code + 'check'"
                              :disabled="item.disabled"
                              type="text"
                              size="default"
                              @click="checkRecordClickFn(scope)"
                            >
                              复核
                            </el-button>
                            <el-button
                              :disabled="
                                scope.row.data.witnessScene === 'STOP' || scope.row.data.witnessScene === 'RECOVER'
                              "
                              v-if="item.code === 'OPERATE_WITNESS_RECORD_DELETE'"
                              :key="item.code + 'del'"
                              type="text"
                              size="default"
                              @click="deleteRecordClickFn(scope)"
                            >
                              删除
                            </el-button>
                          </template>
                        </div>
                        <!-- <el-button type="text" size="default" @click="editRscope)"
                  >编辑</el-button
                >
                <el-button type="text" size="default" @click="updateClickFn"
                  >提交</el-button
                >
                <el-button type="text" size="default" @click="updateClickFn"
                  >确认</el-button
                >
                <el-button type="text" size="default" @click="enterClickFn"
                  >删除</el-button
                > -->
                      </template>
                    </el-table-column>
                  </el-table>
                </div>
                <!-- 附件 -->
                <div>
                  <div class="ui-title ui-mt10">附件</div>
                  <!-- 列表 -->
                  <div class="ui-mt10">
                    <div class="table-box">
                      <el-table :data="attachment" isdrag>
                        <el-table-column type="index" align="center" :index="indexFn" label="序号" width="50" />
                        <el-table-column prop="itemName" label="事项说明" min-width="150" />
                        <el-table-column prop="attachmentName" label="附件名称" min-width="200">
                          <template slot-scope="scope" row-click>
                            <el-button type="text" size="default" @click="handleAttachView(scope)">
                              {{ scope.row.attachmentName }}
                            </el-button>
                          </template>
                        </el-table-column>
                        <el-table-column prop="attachmentType" label="附件类型" width="100" />
                        <el-table-column prop="createTime" label="接收时间" min-width="120" />
                        <el-table-column label="来源" min-width="100">
                          <template slot-scope="scope">
                            {{ scope.row.isSystem === "NO" ? scope.row.source : scope.row.sysName }}
                          </template>
                        </el-table-column>
                        <el-table-column label="操作" header-align="left" width="110">
                          <template slot-scope="scope">
                            <el-button type="text" size="default" @click="downloadAttachFn(scope)">下载</el-button>
                            <el-button
                              v-if="scope.row.isSystem === 'NO' && !managerFlag"
                              type="text"
                              size="default"
                              @click="deleteAttachFn(scope)"
                            >
                              删除
                            </el-button>
                          </template>
                        </el-table-column>
                      </el-table>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <!-- 分页 -->
            <div class="layout-footer ui-pt10">
              <!-- {{ pageObj.total + " " + pageObj.pageSize }} -->
              <pagination
                v-if="pageObj.total > pageObj.pageSizes[0] && this.pageObj.pageSize != -1"
                :total="pageObj.total"
                :page.sync="pageObj.currentPage"
                :limit.sync="pageObj.pageSize"
                :page-sizes="pageObj.pageSizes"
                @pagination="witnessRecordListFn"
              />
            </div>
          </div>
        </div>
        <!-- <div class="" v-else>
      <el-result icon="empty1" title="暂无数据" :size="180"></el-result>
    </div> -->
        <el-dialog title="结束见证" :visible.sync="finishVisible" width="500px" class="cancel-dialog">
          <div class="info-box">
            <i class="el-icon-warning" />
            请确认当前见证的交易活动已结束，确认无误后进行结束见证操作。
            <br />
            <br />
            结束见证时将自动执行见证事项【确认】操作。
            <br />
            结束见证后当前见证子任务可在1小时内再次开启见证。
          </div>
          <span slot="footer">
            <el-button type="primary" :loading="cancelLoading" @click="submitCodeDialogFn">确定</el-button>
            <el-button @click="closeCodeDialogFn">取消</el-button>
          </span>
        </el-dialog>
        <!-- 移交见证 -->
        <el-dialog title="移交见证" :visible.sync="yiJiaoVisible" width="500" draggable custom-class="dialog-demo">
          <div>
            <span class="warning">!</span>
            移交见证任务后该任务将从当前列表中移除，请确认无误后进行移交。
          </div>
          <el-form ref="formSubt" :model="formSubt" label-width="auto" label-max-width="140px" :rules="rulesyj">
            <el-form-item label="移交给" prop="witnessSubTaskIdList">
              <el-select v-model="formSubt.witnessSubTaskIdList" placeholder="请选择" @change="yiJiaoChange">
                <el-option
                  v-for="(item, index) in subtaskList"
                  :key="index"
                  :label="item.userName"
                  :value="item.userId"
                />
              </el-select>
            </el-form-item>
            <el-form-item label="移交原因" prop="reason">
              <el-input
                v-model="formSubt.reason"
                type="textarea"
                placeholder="请输入移交原因"
                :rows="4"
                maxlength="200"
                show-word-limit
              />
            </el-form-item>
            <el-form-item class="dialog-footer">
              <span>
                <el-button type="primary" @click="submitYj('formSubt')">确定</el-button>
                <el-button @click="cancelYj('formSubt')">取消</el-button>
              </span>
            </el-form-item>
          </el-form>
        </el-dialog>
        <vCodeDialog
          header-title="删除"
          :show="deleteVisible"
          message="请确认删除当前见证记录。"
          @submit="witnessRecordDeleteFn"
          @close="closeDeleteDialogFn"
        />
        <!--
          @submit2="addMattersSubmitFn"  -->
        <vWorkBenchAddMatters
          ref="vWorkBenchAddMatters"
          :init-data="TASKOBJ"
          :matter-type="matterType"
          :curr-data="currProjectData"
          :top-task-active.sync="topTaskActive"
          :visible.sync="addMattersVisible"
          :show="addMattersVisible"
          @close="closeAddMattersDialogFn"
          @scrollView="scrollView"
          @fatherNodeTab="fatherNodeTab"
        />
        <!-- 暂停记录弹框 -->
        <vStopRecord
          :init-data="TASKOBJ"
          :id="id"
          :type="stopType"
          :visible.sync="stopRecordVisible"
          :show="stopRecordVisible"
          @close="closeStopRecordDialogFn"
          @updateBenchFn="updateBenchFn"
        />
        <vAddtask
          :init-data="TASKOBJ"
          :show="addTaskVisible"
          @submit2="addTaskSubmitFn"
          @close="closeAddTaskDialogFn"
        />
        <!--见证记录 编辑、复核 编辑见证事项/复核见证事项-->
        <el-dialog
          :title="checkRecordId ? '复核见证事项' : '编辑见证事项'"
          :visible.sync="jzsxVisible"
          width="500px"
          draggable
          custom-class=""
          :before-close="cancelRecordClickFn"
        >
          <!-- <div>
        <span class="warning">!</span>
      </div> -->
          <el-form ref="formJZSX" :model="currentRowData" label-width="auto" label-max-width="140px" :rules="rules">
            <el-form-item label="见证事项">
              {{ currentRowData.parentItemName }}
            </el-form-item>
            <el-form-item label="状态">
              <el-radio-group v-model="currentRowData.itemStatus" @change="rowStartusChangeFn(currentRowScope)">
                <el-radio label="NORMAL_TYPE">正常</el-radio>
                <el-radio label="EXCEPTION_TYPE">异常</el-radio>
              </el-radio-group>
            </el-form-item>
            <!-- {{ currentRowScope.matterInstruction }} -->
            <el-form-item label="事项说明">
              <!-- @change="rowItemCodeChangeFn" -->
              <!-- {{ currentRowData.itemCodes }} -->
              <el-cascader
                v-model="currentRowData.itemCodes"
                style="width: 100%"
                option-max-width="300px"
                :props="{ multiple: false }"
                :options="currentRowScope.matterInstruction"
                @change="itemCodesChangeFn"
              />
            </el-form-item>
            <!--
                :picker-options="pickerOptions" -->
            <!-- {{ currentRowData.occurrentTime }} -->
            <!-- {{ currentRowData }} -->
            <el-form-item label="发生时间">
              <el-date-picker
                :disabled="currentRowData.witnessScene === 'RECOVER' || currentRowData.witnessScene === 'STOP'"
                v-model="currentRowData.occurrentTime"
                style="width: 100%"
                unlink-panels
                type="datetime"
                :clearable="true"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss"
              />
            </el-form-item>
            <el-form-item label="见证记录">
              <el-input
                v-model.trim="currentRowData.witnessRecordDesc"
                type="textarea"
                placeholder="请输入内容"
                maxlength="200"
                :rows="2"
                show-word-limit
              />
            </el-form-item>
            <el-form-item class="dialog-footer">
              <span>
                <el-button :loading="btnLoading" type="primary" @click="saveRecordClickFn()">保存</el-button>
                <!-- <el-button v-if="checkRecordId"
              type="text"
              size="default"
              @click="checkRecordClickFn(scope)"
              >复核</el-button
            > -->
                <el-button @click="cancelRecordClickFn()">取消</el-button>
              </span>
            </el-form-item>
          </el-form>
        </el-dialog>
      </div>
    </div>
    <el-dialog
      title="提示"
      :visible.sync="confirmVisible"
      width="420px"
      custom-class="dialog-confirm"
      :show-close="false"
      :close-on-click-modal="false"
      :close-on-press-escape="false"
    >
      <div class="content-box">
        <i class="el-icon-warning"></i>
        <span>您当前见证的{{ currProjectData.witnessSubTaskName }}环节已待定，即将关闭页面</span>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="confirmFn(currProjectData)">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
  const topTaskActiveParamMap = {
    'KB': {
      address: 'openAddress',
      startTime: 'openStartTime',
    },
    'PB': {
      address: 'evaluationAddress',
      startTime: 'evaluationStartTime',
    },
    'QB': {
      address: 'preClearAddress',
      startTime: 'preClearStartTime',
    }
  };
  import gTimer from "../../components/timer.vue";
  import vCodeDialog from "../../components/dialog/VerificationCode.vue";
  import vAddtask from "../../components/dialog/Addtask.vue";
  // import vWorkTaskList from "../../components/WorkTaskList.vue";
  import vWorkBenchAddMatters from "../../components/dialog/WorkBenchAddMatters.vue";
  import vStopRecord from "../../components/dialog/StopRecord.vue";
  import {
    moduleInit,
    subtaskListOwner,
    witnessRecordList,
    itemDictList,
    witnessRecordAdd,
    newInfoRecordQuerylist,
    witnessRecordClicks,
    witnessRecordConfirmOne,
    witnessRecordUpdate,
    witnessRecordDelete,
    subtaskFinish,
    subtaskTimeDiff,
    // warnRecordList,
    subtaskListPart,
    subtaskInfo,
    subtaskPermissionUser,
    subtaskAllocateUser,
    ruleList,
    uploadFile,
    getAttachmentList,
    deleteAttachment,
    witnessSubtaskPendConfirm
  } from "../../api/api.js";
  import { FindArrayFn as findArrayFn, isOneH } from "../../utils/utils";
  import { mapActions } from "vuex";
  import gzAddReviewTime from "../../../gz_plugin/components/gz-add-review-time";
  import gzOverWitness from "../../../gz_plugin/components/gz-over-witness";
  import { GZAPI_EvaluationTime } from "../../../gz_plugin/api";
  export default {
    // vWorkTaskList
    components: { gTimer, vCodeDialog, vAddtask, vWorkBenchAddMatters, vStopRecord, gzAddReviewTime, gzOverWitness },
    // 预警级别校验暂时隐藏
    // status: [
    //   {
    //     message: "选择等级不能为空",
    //     validator: (rule, value, callback) => {
    //       console.log(value);
    //       if (
    //         this.addform.matterStatus !== "NORMAL_TYPE" &&
    //         !this.addform.warningLevel
    //       ) {
    //         callback(new Error("选择等级不能为空"));
    //       } else {
    //         callback();
    //       }
    //     },
    //     trigger: "blur",
    //   }
    // ],
    // keyWord: [{ required: true, message: "key不能为空", trigger: "blur" }],
    // witnessSubTaskIdList: [
    //   { required: true, message: "事项说明不能为空", trigger: "change" },
    // ],
    // eslint-disable-next-line max-lines-per-function
    data() {
      return {
        originalData:[],
        processedData: {
          datalist: [], // 处理过后的数组
          isShowTaskAll: true,
          selectProductId: "", // 选中的项目Id
          selectProductIndex: "", // 选中的项目下标
          selectTaskId: "", // 选中的标段的Id
          selectTaskIndex: "", // 选中的标段的下标
          _taskIndex:'' // 当前标段在该项目中的下标
        },
        confirmVisible: false,
        loading: false,
        breadPathList: [
          {
            path: "/WitnessTaskManagement/WitnessTaskView",
            title: "见证任务管理"
          }
        ], // 管理员从“见证任务查看”模块跳转过来时，需要显示的面包屑
        matterType: "",
        className: "",
        witnessStatus: "",
        subtaskTimeDiffTotle: null,
        subtaskTimeDiffStopTotle: null,
        cancelLoading: false,
        updateOverFlag: true,
        leftRightBtnFlag: false,
        topTaskVisible: true,
        yiJiaoVisible: false,
        finishVisible: false,
        deleteVisible: false,
        addTaskVisible: false,
        addMattersVisible: false,
        finishWitnessBtnFlag: false,
        pauseWitnessVisible: false,
        stopRecordVisible: false,
        stopType: "",
        jzsxVisible: false,
        btnLoading: false,
        checkRecordId: "",
        parentItemCodeGl: "",
        stepActive: 0,
        deleteRow: {},
        deleteIndex: null,
        pageObj: {
          total: 0,
          currentPage: 1,
          pageSize: 10,
          pageSizes: [10, 20, 30]
        },
        pageQueryList: {
          total: 0,
          currentPage: 1,
          pageSize: 10,
          pageSizes: [10, 20, 30]
        },
        formSubt: {
          witnessSubTaskIdList: "",
          reason: "",
          userId: ""
        },
        witnessMatterOptions: [],
        matterInstruction: [],
        currProjectData: {},
        currentRowData: {},
        currentRowScope: {},
        sideRecordActive: "first",
        topTaskActive: "",
        submitLoading: false,
        sideFold: false,
        reverse: false,
        TASKOBJ: {},
        id: "",
        subtaskList: [],
        recordData: [],
        topTaskAllData: {},
        topTaskYujingData: {},
        topTaskData: [],
        rules: {
          taskMatterCode: [{ required: true, message: "见证事项不能为空", trigger: "blur" }],
          itemCodeList: [{ required: true, message: "事项说明不能为空", trigger: "change" }],
          witnessRecordDesc: [
            {
              required: true,
              message: "见证记录不能为空",
              trigger: ["change", "blur"]
            }
          ]
        },
        ruleForm: {},
        rulesyj: {
          witnessSubTaskIdList: [{ required: true, message: "移交人不能为空", trigger: "blur" }],
          reason: [{ required: true, message: "移交原因不能为空", trigger: "blur" }]
        },
        matterKeyWord: "",
        activitiesNoDataFlag: false,
        activitiesOld: [],
        activities: [],
        addform: {
          matterStatus: "NORMAL_TYPE",
          taskMatterCode: [],
          itemCodeList: [],
          witnessRecordDesc: "",
          warningLevel: "",
          attachmentList: []
        },
        tableData: [{}],
        taskListFlag: false,
        attachment: [],
        subscribedUrlArr: [] // 记录已经订阅的ws的url通道
      };
    },
    computed: {
      managerFlag() {
        return (
          this.$store.getters.roleCode === "GDW_R_WITNESS_MANAGER" ||
          this.$store.getters.roleCode === "GDW_R_WITNESS_SUPER"
        );
        // return this.$store.getters.roleCode==="GDW_R_WITNESS_PERSON"
      },
      wsData() {
        return this.$websocket.getters.wsData;
      },
      nettyPendData() {
        return this.$websocketNettyPend.getters.pendData;
      },
      topTaskActiveLabel(){
        return this.TASKOBJ.taskWitnessLinkAll.find(item => item.value === this.topTaskActive).label
      }
    },
    watch: {
      topTaskYujingData: {
        handler(val) {
          console.log("topTaskYujingData", val);
          console.log("refs", this.$refs.dialogTaskList);
          clearTimeout(this.yujingTimeFlag);
          this.yujingTimeFlag = setTimeout(() => {
            this.setTopTaskYujingData(val);
          }, 200);
        },
        immediate: true
      },
      topTaskAllData: {
        handler(val) {
          console.log("topTaskAllData", val);
          console.log("refs", this.$refs.dialogTaskList);
          clearTimeout(this.taskTimeFlag);
          this.taskTimeFlag = setTimeout(() => {
            this.setTopTaskAllData(val);
          }, 200);
        },
        immediate: true
      },
      topTaskData(newTopTaskData, lod) {
        console.log("aaaaaaa");
        // 这里需要设计一下，dom渲染完在计算宽度 by link
        if (this.$refs.refTaskList) {
          this.$nextTick(() => {
            this.leftRightBtnFlag =
              this.$refs.refTaskList && this.$refs.refTaskList.scrollWidth > this.$refs.refTaskList.clientWidth;
          });
        }
        if(newTopTaskData.length > 0){
          this.originalData = this.ganTopTaskData(newTopTaskData);
          this.selectTaskById(this.id)
        }
      },
      topTaskActive(val) {
        console.log("val", val);
        if (val) {
          // 这会影响首次加载，故注释了
          // this.stepsClickFn();
        }
      },
      wsData: {
        handler(newVal) {
          console.log("ws消息变化================", newVal);
          // 嵌套的最大深度 5
          if (!newVal) {
            return;
          }
          console.log("newVal.witnessRecordList", newVal.witnessRecordList);
          console.log("this.id", this.id);
          // 见证记录
          if (
            newVal.witnessRecordList &&
            newVal.witnessRecordList[0] &&
            newVal.witnessRecordList[0].witnessSubTaskId === this.id
          ) {
            console.log("aaa");
            // 有编辑转态不能刷新
            setTimeout(() => {
              console.log("this.recordData", this.recordData);
              const f = this.recordData.some((item) => item.edit);
              console.log("f", f);
              if (!f) {
                // this.pageObj.currentPage = 1;
                this.witnessRecordListFn();
              }
            }, 300);
          }
          // 全部信息、预警信息
          if (newVal.witnessInfoRecord) {
            if (newVal.witnessInfoRecord.witnessSubTaskId === this.id) {
              // 这里刷新
              if (this.sideRecordActive === "first") {
                this.pageQueryList.currentPage = 1;
                this.infoRecordQuerylistFn();
              } else {
                this.pageQueryList.currentPage = 1;
                this.warnRecordQuerylistFn();
              }
              // this.activities.unshift(newVal.witnessInfoRecord);
              // this.activitiesOld.unshift(newVal.witnessInfoRecord);
            }
            // else {
            // await this.webSocketTaskFn(this.topTaskAllData["ZB"]);
            // let yujingData = {};
            // 管理员
            if (
              this.currProjectData.witnessSubTaskId === newVal.witnessInfoRecord.witnessSubTaskId &&
              newVal.witnessInfoRecord.witnessStatus === "EXCEPTION"
            ) {
              this.currProjectData.isWarn = true;
            }
            // 见证人员
            for (const key in this.topTaskAllData) {
              if (Object.hasOwnProperty.call(this.topTaskAllData, key)) {
                const taskData = this.topTaskAllData[key];
                console.log("taskData", key, taskData);
                for (let i = 0; i < taskData.length; i++) {
                  const item = taskData[i];
                  if (
                    item.witnessSubTaskId === newVal.witnessInfoRecord.witnessSubTaskId &&
                    newVal.witnessInfoRecord.witnessStatus === "EXCEPTION"
                  ) {
                    // console.log("taskData",item.witnessSubTaskId ===
                    //   newVal.witnessInfoRecord.witnessSubTaskId);
                    // console.log("taskData",newVal.witnessInfoRecord.witnessStatus);
                    // console.log("3333333", i);
                    // console.log("3333333", key);
                    // let jylcType = taskData[i].jylcType;
                    // yujingData[key] ={isWarn:true} ;
                    // if (!this.topTaskYujingData[key].isWarn) {
                    //   }
                    this.$set(this.topTaskYujingData, key, { isWarn: true });
                    // let data=this.topTaskAllData[key][i]
                    this.$set(this.topTaskAllData[key][i], "isWarn", true);
                    // this.$set(this.topTaskData[i], "isWarn", true);
                    break;
                  }
                }
              }
            }
            console.log("3333333", this.topTaskYujingData);
            // this.topTaskYujingData =yujingData;
            // this.topTaskData.forEach((item, index) => {});
            // }
          }
          // if (newVal.witnessRecord) {
          //   console.log("newVal.witnessRecord", newVal.witnessRecord);
          // }
        },
        immediate: true
      },
      nettyPendData: {
        handler(newVal) {
          console.log("netty ws消息变化===============nettyPendData=", newVal);
          if (!newVal || !newVal.data) {
            return;
          }
          console.log("newVal.witnessRecordList", newVal.witnessRecordList);
          console.log("this.id", this.id);
          // 每次处理1个项目的待定
          Object.keys(newVal.data).forEach((key) => {
            console.log("key", key);
            this.topTaskAllData[key] &&
              this.topTaskAllData[key].forEach((item) => {
                console.log("item", item);
                if (item.bidSectionCode === newVal.data[key].bidSectionCode) {
                  item.witnessSubTaskStatusEnum = "WITNESS_PENDING";
                  // 当前选中触发this.currProjectData的监听
                  if (this.currProjectData.bidSectionCode === newVal.data[key].bidSectionCode) {
                    this.$set(this.currProjectData, "witnessSubTaskStatusEnum", "WITNESS_PENDING");
                    this.$set(this.currProjectData, "nowtime", new Date());
                  }
                }
              });
          });
          console.log("this.topTaskAllData===s", this.topTaskAllData);
        },
        immediate: true
      },
      currProjectData: {
        handler(newVal) {
          console.log("currProjectData============ ", newVal);
          // if (this.setTimeoutFlag) {
          //   return;
          // }
          clearTimeout(this.setTimeoutFlag);
          this.setTimeoutFlag = setTimeout(() => {
            this.setTimeoutFlag = null;
            console.log("currProjectData---", newVal);
            // 判断待定
            // ||
            // newVal.witnessSubTaskId === "8a804c1c80f3c2ce0180f4b341c2008e"
            if (newVal.witnessSubTaskStatusEnum === "WITNESS_PENDING") {
              this.confirmVisible = true;
              // this.$confirm(`您当前见证的${开标 / 清标 / 评标}环节已待定，即将关闭页面`, "提示", {
              // this.$msgbox({
              //   title: "提示",
              //   type: "warning",
              //   message: `您当前见证的${newVal.witnessSubTaskName}环节已待定，即将关闭页面`,
              //   closeOnPressEscape: false,
              //   closeOnClickModal: false,
              //   showClose: false,
              //   showCancelButton: false,
              //   confirmButtonText: "确定",
              //   beforeClose: async (action, instance, done) => {
              //     if (action === "confirm") {
              //       this.confirmFn(newVal);
              //       done();
              //     } else {
              //       done();
              //     }
              //   }
              // });
            }
          }, 350);
        },
        immediate: true
      },
      taskListFlag() {
        if (this.$refs.refTaskList) {
          console.log("leftRightBtnFlag", this.$refs.refTaskList.scrollWidth);
          console.log("leftRightBtnFlag", this.$refs.refTaskList.clientWidth);
        }
        setTimeout(() => {
          this.leftRightBtnFlag =
            this.$refs.refTaskList && this.$refs.refTaskList.scrollWidth > this.$refs.refTaskList.clientWidth;
        }, 500);
      },
      processedData: {
        deep: true,
        handler(newProcessedData) {
          const { isShowTaskAll, selectProductIndex, _taskIndex } = newProcessedData;
          let scrollLeft;
          // 如果是展开的
          if (isShowTaskAll) {
            scrollLeft = (401 * selectProductIndex) + (383 * _taskIndex);
          } else {
            scrollLeft = (401 * selectProductIndex);
          }
          this.$nextTick(() => {
            const witnessCollapseBody = document.getElementById("witnessCollapseBody")
            if (witnessCollapseBody) {
              scrollLeft -= (witnessCollapseBody.clientWidth - 401)/2;
              document.getElementById("witnessCollapseBody").scrollLeft = scrollLeft;
            }
          });
        }
      },
      'processedData.selectTaskId'(n){
        for (let i = 0; i < this.topTaskData.length; i++) {
          if(n === this.topTaskData[i].witnessSubTaskId){
            this.projectClickFn(this.topTaskData[i], i)
            break
          }
        }
      }

    },
    activated() {
      console.log("activated");
      this.initScriptFn();
    },
    deactivated() {
      // 管理员、-浏览器-后退按钮
      console.log("deactivated");
      this.id = "";
      this.initFromFn();
      this.subscribedUrlArr.forEach((url) => {
        // 断开ws订阅通道
        this.$websocket.dispatch("websocket_unsubscribe", url);
      });
    },
    created() {
      console.log('this.$router.path', this.$route);
      this.initScriptFn();
    },
    beforeDestroy() {
      console.log("beforeDestroy");
      this.confirmVisible = false;
      this.recordData = [];
      this.initFromFn();
      this.subscribedUrlArr.forEach((url) => {
        // 断开ws订阅通道
        this.$websocket.dispatch("websocket_unsubscribe", url);
      });
    },
    mounted() {
      this.$nextTick(() => {
        // 代码保证 this.$el 在 document 中
        document.addEventListener("click", (e) => {
          // console.log("e", e.target);
          // console.log("this.$refs.topTaskBox", this.$refs.topTaskBox);
          // console.log("this.$refs.changeTaskBtn", this.$refs.changeTaskBtn);
          if (this.$refs.changeTaskBtn && this.$refs.changeTaskBtn.$el.contains(e.target)) {
            // this.taskListFlag = true;
          } else if (this.$refs.topTaskBox && !this.$refs.topTaskBox.contains(e.target)) {
            this.taskListFlag = false;
          }
        });
      });
    },
    methods: {
      // 跳到空白页面
      navBlankPage(path){
        this.$router.replace({
          path:'/blankPage',
          query:{
            path,
          }
        })
      },


      async confirmFn(newVal) {
        this.confirmVisible = false;
        // 调删除接口，从列表中删除
        try {
          const p = { witnessSubTaskId: newVal.witnessSubTaskId };
          await witnessSubtaskPendConfirm(p);
        } catch (error) {
          console.warn(error);
        }
        // this.delTask(newVal.witnessSubTaskId)
        console.log("this.topTaskAllData", this.topTaskAllData);
        if (newVal.witnessLinkCode === "FP") {
          newVal.witnessLinkCode = "PB";
        }
        if (this.topTaskAllData[newVal.witnessLinkCode].length) {
          const index = this.topTaskAllData[newVal.witnessLinkCode].findIndex(
            (item) => item.witnessSubTaskId === newVal.witnessSubTaskId
          );
          console.log("index", index);
          // this.$set(
          //   this.topTaskAllData,
          //   newVal.witnessLinkCode,
          this.topTaskAllData[newVal.witnessLinkCode].splice(index, 1);
          // );
        }
        console.log(
          "this.topTaskAllData[newVal.witnessLinkCode]",
          JSON.stringify(this.topTaskAllData[newVal.witnessLinkCode])
        );
        this.$nextTick(async () => {
          if (this.topTaskAllData[newVal.witnessLinkCode].length) {
            this.id = this.topTaskAllData[newVal.witnessLinkCode][0].witnessSubTaskId; // this.topTaskAllData.
          } else {
            this.id = "";
          }
          this.addMattersVisible = false;
          this.stopRecordVisible = false;
          this.yiJiaoVisible = false;
          this.finishVisible = false;
          this.addTaskVisible = false;
          console.log("id", this.id);
          this.$router.replace({
            // path: "/Workbench",
            query: {
              id: this.id
            }
          });
          await this.initFn();
        });
      },
      // wei点击后进入见证页签定位可视区域
      scrollView(childObj) {
        if (Object.prototype.toString.call(childObj) === "[object Object]") {
          if (childObj.name === "child") {
            this.id = childObj.child;
            this.$nextTick(() => {
              document.getElementById(childObj.child)?.scrollIntoView(true);
            });
          }
        } else if (childObj) {
          this.$nextTick(() => {
            document.getElementById(childObj)?.scrollIntoView(true);
          });
        } else {
          this.$nextTick(() => {
            document.getElementById(this.$route.query.id)?.scrollIntoView({ block: "center", inline: "start" });
          });
        }
        this.checkRecordFn();
      },
      nodeScrollView(tabName, queryId) {
        if (queryId) {
          if (this.addMattersVisible) {
            this.$refs.vWorkBenchAddMatters.childWorkTab(tabName, queryId);
            this.$refs.vWorkBenchAddMatters.childWorkList(queryId);
          }
          this.scrollView(queryId);
        }
      },
      async fatherNodeTab(tab, tabId) {
        this.topTaskActive = tab;
        await this.checkRecordFn("tab");
        if (!tabId) {
          this.$nextTick(() => {
            document.getElementById(tabId)?.scrollIntoView(true);
          });
        }
      },
      // ---------------wei
      ...mapActions({ setTopTaskYujingData: "SET_topTaskYujingData", setTopTaskAllData: "SET_topTaskAllData" }),
      /**
       * 根据标包Id,代开项目,并且,该标包选中
       * @param taskId
       */
      selectTaskById(taskId) {
        const { originalData } = this;
        for (let i = 0; i < originalData.length; i++) {
          if (originalData[i].taskList.find(item => item.tn === taskId)) {
            this.anProduct(originalData[i].pn, taskId);
            return;
          }
        }
      },

      /**
       * 根据项目ID,打开项目,并且默认选中,第一个标包
       * @param taskId
       */
      anProductDefaultFirstTask(productId, isOneTask) {
        const { originalData, processedData } = this;
        if (processedData.selectProductId === productId && processedData.isShowTaskAll === false) {
          if (isOneTask) {
            return;
          }
          this.processedData.isShowTaskAll = true;
          return;
        }
        for (let i = 0; i < originalData.length; i++) {
          if (originalData[i].pn === productId) {
            this.processedData.isShowTaskAll = true;
            this.anProduct(originalData[i].pn, originalData[i].taskList[0].tn);
            return;
          }
        }
      },
      // 处理工作台 阶段的 标包信息
      ganTopTaskData(topTaskAllDataItem) {
        const topTaskDataMap = {};
        const topTaskData = [];
        let topTaskDataItem;
        const date = new Date();
        // 提取数据
        function extractData(item){
          const {witnessLinkCode} = item;
          const topTaskActiveParam = topTaskActiveParamMap[witnessLinkCode];
          return {
            witnessSubTaskStatusEnum:item.witnessSubTaskStatusEnum,
            openAddress: item.openAddress,
            evaluationAddress:isOneH(item.evaluationStartTime, date) ? item.evaluationAddress : '**',
            address: topTaskActiveParam ? item[topTaskActiveParam.address] : '',
            startTime: topTaskActiveParam ? item[topTaskActiveParam.startTime] : ''
          }
        }

        topTaskAllDataItem.forEach(item => {
          if(`${item.projectCode}` in topTaskDataMap){
            topTaskDataItem = topTaskDataMap[`${item.projectCode}`];
            topTaskDataItem.taskList.push({
              tn: item.witnessSubTaskId,
              ...item
            })
          } else {
            topTaskDataItem  = {
              pn:item.projectCode,
              projectCode: item.projectCode,
              projectName: item.projectName,
              ...extractData(item),
              taskList: [{
                tn: item.witnessSubTaskId,
                ...item
              }]
            }
            topTaskDataMap[`${item.projectCode}`] = topTaskDataItem;
          }
        })

        for (let topTaskDataMapKey in topTaskDataMap) {
          topTaskData.push(topTaskDataMap[topTaskDataMapKey]);
        }
        return topTaskData;
      },


      /**
       * 通过id修改选中效果
       * @param productId
       * @param taskId
       */
      anProduct(productId, taskId) {
        const {processedData, originalData } = this;
        const { selectProductId, selectTaskId } = processedData;
        let isShowTaskAll;

        // // 防止重复选中
        // if (productId === selectProductId && taskId === selectTaskId) {
        //   return;
        // }

        // 防止没有数据, 无线循环
        if (originalData.length === 0) {
          return;
        }

        let isSelectProduct, isSelectTask, productIndex, taskIndex, _taskIndex;


        function _genData() {
          return originalData.reduce((arr, item, _productIndex) => {
            arr.push({
              isSelectProduct: item.pn === productId, // 是否选中项目
              isOneTask:item.taskList.length === 1,
              isShowProductTaskAll: true,
              ...item,
              type: "PRODUCT"
            });
            if (item.pn === productId) {
              isSelectProduct = true;
              productIndex = _productIndex;
              item.taskList[0].isFirst = true;
              item.taskList[item.taskList.length - 1].isLast = true;
              arr.push(
                ...item.taskList.map((item, _tIndex) => {
                  if (item.tn === taskId) {
                    _taskIndex = _tIndex;
                    taskIndex = _taskIndex + _productIndex + 1;
                    isSelectTask = true;
                  }
                  item.type = "TASK";
                  return {
                    ...item,
                    _taskIndex:_tIndex,
                    isSelectTask: item.tn === taskId,
                    productId: productId,
                    productIndex: productIndex
                  };
                })
              );
              isShowTaskAll = item.taskList.length > 1
            }
            return arr;
          }, []);
        }

        let datalist = _genData();
        if ((!isSelectProduct || !isSelectTask) && originalData.length > 0 && originalData[0].taskList.length > 0) {
          productId = originalData[0].pn;
          taskId = originalData[0].taskList[0].tn;
          datalist = _genData();
        }
        this.$set(this.processedData, 'datalist', datalist);
        // this.processedData.datalist = datalist;
        this.processedData.selectProductId = productId;
        this.processedData.selectProductIndex = productIndex;
        this.processedData.selectTaskId = taskId;
        this.processedData.selectTaskIndex = taskIndex;
        this.processedData._taskIndex = _taskIndex;
        this.processedData.isShowTaskAll = isShowTaskAll;
      },
      // 根据下标, 切换标包
      selectTaskByIndex(index, taskId, _taskIndex) {
        if(this.processedData.selectTaskId === taskId){
          return;
        }

        this.processedData.datalist[index].isSelectTask = true;
        this.processedData.datalist[this.processedData.selectTaskIndex].isSelectTask = false;
        this.processedData.selectTaskId = taskId;
        this.processedData.selectTaskIndex = index;
        this.processedData._taskIndex = _taskIndex;
      },
      /**
       * 关闭当前打开的项目
       */
      hiddenTaskAll() {
        this.processedData.isShowTaskAll = false;
      },


      ...mapActions(["SET_topTaskYujingData", "SET_topTaskAllData"]),
      // 管理员返回方法
      handleBackFn() {
        console.log("handleBackFn");
        this.recordData = [];
        this.id = "";
        this.initFromFn();
        this.subscribedUrlArr.forEach((url) => {
          // 断开ws订阅通道
          this.$websocket.dispatch("websocket_unsubscribe", url);
        });
        this.$router.replace({ path: "/WitnessTaskManagement/WitnessTaskView" });
      },
      async initScriptFn() {
        this.id = this.$route.query.id; // || sessionStorage.getItem("witnessSubTaskId");
        this.witnessLinkCode = this.$route.query.type;
        if (this.initTimeFlag) {
          return;
        }
        this.initTimeFlag = setTimeout(() => {
          clearTimeout(this.initTimeFlag);
          this.initTimeFlag = null;
        }, 200);
        this.initFromFn();
        await this.ruleListFn(); //
        await this.moduleInitFn();
        await this.initFn(); //
        // return;
      },
      updateBenchFn() {
        this.initFn();
      },
      // 暂停记录按钮
      stopRecordBtnFn(flag) {
        console.log("flag", flag);
        this.stopType = flag || "edit";
        this.stopRecordVisible = true;
      },
      // 查询见证状态
      async ruleListFn() {
        try {
          const p = {};
          const res = await ruleList(p);
          if (res.success) {
            // eslint-disable-next-line prefer-destructuring
            this.ruleForm = res.data[0];
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (err) {
          console.error(err);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      taskLeftFn() {
        console.log("this.$refs.refTaskList.scrollLeft", this.$refs.refTaskList.scrollLeft);
        console.log("this.$refs.refTaskList.scrollWidth", this.$refs.refTaskList.scrollWidth);
        console.log("this.$refs.refTaskList.clientWidth", this.$refs.refTaskList.clientWidth);
        this.$refs.refTaskList.scrollLeft -= 600;
      },
      taskRightFn() {
        console.log("this.$refs.refTaskList.scrollLeft", this.$refs.refTaskList.scrollLeft);
        this.$refs.refTaskList.scrollLeft += 600;
      },
      // 结束见证弹框事件
      submitCodeDialogFn() {
        this.finishVisible = false;
        this.subtaskFinishFn();
      },
      closeCodeDialogFn() {
        this.finishVisible = false;
        this.cancelLoading = false;
      },
      async closeAddMattersDialogFn(flag) {

        // 获取暂停时长
        await this.subtaskTimeDiffFn();
        if (flag === "save") {
          this.$refs.vWorkBenchAddMatters.loading = false;
          if (this.matterType === "STOP") {
            this.currProjectData.witnessSubTaskStatusEnum = "WITNESS_STOP";
          }
          if (this.matterType === "RECOVER") {
            this.currProjectData.witnessSubTaskStatusEnum = "WITNESSING";
            if (this.finishWitnessBtnFlag) {
              this.finishWitnessBtnFlag = false;
              this.$nextTick(() => {
                this.finishWitnessFn();
              });
            }
          }
          // await this.subtaskListPartFn()
          // 更新见证事项列表
          await this.witnessRecordListFn();
          this.navBlankPage(this.$route.fullPath)
        }
        this.finishWitnessBtnFlag = false;
        this.addMattersVisible = false;


      },
      // 关闭暂停见证
      closeStopRecordDialogFn() {
        this.stopRecordVisible = false;
        // 更新见证事项列表
        // this.witnessRecordListFn();
      },
      closeDeleteDialogFn() {
        this.deleteVisible = false;
      },
      closeAddTaskDialogFn() {
        console.log("ccc");
        this.addTaskVisible = false;
      },
      // 新增事项
      addMattersClick() {
        console.log(this.currProjectData, "666766767676");
        this.matterType = "add";
        this.addMattersVisible = true;
        // wei页签联动新增弹框调用子组件方法
        this.checkRecordFn();
        // ----------------wei
      },
      // 暂停见证
      subtaskPauseClick() {
        if (this.addMattersVisible) {
          this.$message({
            type: "error",
            message: "暂停见证前，请提交关闭新增见证事项弹框",
            single: true
          });
          return;
        }
        this.matterType = "STOP";
        this.addMattersVisible = true;
      },
      // 恢复见证
      subtaskRecoverClick() {
        if (this.addMattersVisible) {
          this.$message({
            type: "error",
            message: "恢复见证前，请提交关闭新增见证事项弹框",
            single: true
          });
          return;
        }
        this.matterType = "RECOVER";
        this.addMattersVisible = true;
      },
      subtaskClick() {
        console.log(this.currProjectData, "666766767676");
        this.subtaskAllocateFn(this.currProjectData.witnessSubTaskId);
      },
      // 移交见证
      async subtaskAllocateFn(id) {
        if (this.addMattersVisible) {
          this.$message({
            type: "error",
            message: "移交见证前，请提交关闭新增见证事项弹框",
            single: true
          });
          return;
        }
        this.yiJiaoVisible = true;
        const p = {
          witnessSubTaskIdList: [id]
        };
        try {
          const res = await subtaskPermissionUser(p);
          if (res.success) {
            this.subtaskList = res.data.data;
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (err) {
          console.error(err);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      cancelYj(formSubt) {
        this.$refs[formSubt].resetFields();
        this.formSubt.witnessSubTaskIdList = "";
        this.yiJiaoVisible = false;
      },
      submitYj(formSubt) {
        this.$refs[formSubt].validate((valid) => {
          if (valid) {
            this.subtaskAllocateUserFn();
            this.yiJiaoVisible = false;
          } else {
            return false;
          }
        });
      },
      yiJiaoChange(e) {
        this.formSubt.userId = e;
      },
      // 移交见证
      async subtaskAllocateUserFn() {
        const p = {
          userId: this.formSubt.userId,
          reason: this.formSubt.reason,
          witnessSubTaskAllocateType: "TRANSFER_ALLOCATE",
          witnessSubTaskIdList: [this.currProjectData.witnessSubTaskId]
        };
        try {
          const res = await subtaskAllocateUser(p);
          if (res.success) {
            this.$message({
              type: "success",
              message: "移交成功",
              single: true
            });
            this.yiJiaoVisible = false;
            this.addTaskSubmitFn("");
            // this.initFn();
            this.formSubt = {};
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (err) {
          console.error(err);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      async initFn(ends) {
        console.log("ends", ends);
        // 1、清空左侧列表
        // 2、清空倒计时
        // 3、清空记录
        this.currProjectData = {};
        this.initFromFn();
        // await this.subtaskListOwnerFn();
        // 以下2个接口放到subtaskListPartFn后调用
        // await this.witnessRecordListFn();
        // await this.infoRecordQuerylistFn(); //
        if (this.witnessLinkCode) {
          this.subtaskInfoFn();
          return;
        }
        if (ends === "ends") {
          // 结束见证
          await this.subtaskListPartFn();
        } else {
          await this.subtaskListPartFn("end");
        }
      },
      async addTaskSubmitFn(id) {
        console.log("this.id", id);
        this.id = id;
        sessionStorage.setItem("witnessSubTaskId", this.id);
        // if (this.topTaskAllData[this.stepActive]) {
        // }
        console.log("this.id", this.id);
        this.$router.replace({
          query: {
            id: this.id
          }
        });
        // this.checkRecordFn();
        await this.initFn();
      },
      // 编辑记录
      async editRecordClickFn({ row, $index }) {
        console.log("edit", row, $index);
        this.currentRowData = {
          ...row.data,
          itemCodes: [row.data.itemCode]
        };
        this.currentRowScope = { row, $index };
        this.updateOverFlag = false; // 标记ws获取数据后
        const p = {
          parentCode: row.data.parentItemCode,
          itemStatus: row.data.itemStatus
        };
        const data = await this.itemDictListFn(p);
        this.currentRowScope.matterInstruction = data; //
        //
        // console.log("data", data);
        // console.log("row.data.witnessRecordDesc", row.data.witnessRecordDesc);
        // console.log("this.checkRecordId", this.checkRecordId);
        // if (this.checkRecordId) {
        //   this.currentRowData.occurrentTime = row.data.witnessRecordDesc.match(
        //     /^(\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}:\d{1,2})/g,
        //     ""
        //   )[0];
        // }
        // console.log("currentRowData", this.currentRowData);
        this.jzsxVisible = true;
        // this.$set(this.recordData[$index], "edit", true);
        // this.$set(
        //   this.recordData[$index],
        //   "oldData",
        //   JSON.parse(JSON.stringify(this.recordData[$index].data))
        // );
        // this.$set(this.recordData[$index].data, "itemCodes", [
        //   this.recordData[$index].data.itemCode,
        // ]);
        // // this.matterInstruction;//添加用
        // let p = {
        //   parentCode: row.data.parentItemCode,
        //   itemStatus: row.data.itemStatus,
        // };
        // const data = await this.itemDictListFn(p);
        // this.$set(this.recordData[$index], "matterInstruction", data);
      },
      // 保存按钮事件
      async saveRecordClickFn() {
        // console.log("row", row);
        // console.log("row.data.witnessRecordDesc", row.data.witnessRecordDesc);
        const { $index } = { ...this.currentRowScope };
        const row = {
          data: this.currentRowData,
          matterInstruction: this.currentRowScope.matterInstruction
        };
        this.btnLoading = true;
        let msg = "";
        // 判断为空
        if (!row.data.itemCodes.length) {
          msg = "事项说明不能为空！";
        }
        if (!row.data.witnessRecordDesc) {
          msg = "见证记录不能为空！";
        }
        if (!row.data.occurrentTime) {
          msg = "发生时间不能为空！";
        }
        // if (row.data.itemStatus === "EXCEPTION_TYPE" && !row.data.warningLevel) {
        // if (row.data.itemStatus === "EXCEPTION_TYPE" && !row.data.warningLevel) {
        //   msg = "级别不能为空！";
        // }
        if (msg) {
          this.$message({
            type: "error",
            message: msg,
            single: true
          });
          this.btnLoading = false;
          return;
        }
        console.log("111");
        console.log("this.checkRecordId", this.checkRecordId);
        console.log("row.data.recordId", row.data.recordId);
        // return;
        // if (row.newAdd) {
        // 复核-有两个逻辑
        if (this.checkRecordId) {
          // 复核-编辑人工
          if (this.checkRecordId !== row.data.recordId) {
            this.$set(
              this.recordData[$index].data,
              "itemName",
              findArrayFn(row.matterInstruction, row.data.itemCodes[0]).label
            );
            await this.witnessRecordUpdateFn($index);
          } else {
            // 复核-保存-调新增
            const { itemCodes } = row.data;
            // .map((item) => {
            //   return item;
            //   // return item[0];多选
            // });
            // this.$set(this.recordData[$index], "edit", false);
            // v-model="scope.row.data.itemCodes"
            // :options="scope.row.matterInstruction"
            const params = {
              itemCodes,
              recordId: row.data.recordId,
              recordSort: row.data.recordSort,
              itemStatus: row.data.itemStatus,
              warningLevel: row.data.itemStatus === "EXCEPTION_TYPE" ? "HEIGHT" : "",
              // warningLevel: row.data.itemStatus === "EXCEPTION_TYPE" ? row.data.warningLevel[0] : "",
              occurrentTime: row.data.occurrentTime,
              witnessRecordDesc: row.data.witnessRecordDesc,
              witnessSubTaskId: this.currProjectData.witnessSubTaskId,
              witnessTaskId: this.currProjectData.witnessTaskId,
              source: this.$store.getters.username || localStorage.getItem("username")
            };
            console.log("params", params);
            // return;
            await this.witnessRecordAddFn(params);
          }
        } else {
          this.$set(
            this.recordData[$index].data,
            "itemName",
            findArrayFn(row.matterInstruction, row.data.itemCodes[0]).label
          );
          await this.witnessRecordUpdateFn($index);
        }
        // 系统推送的复核、确认按钮删除
        this.jzsxVisible = false;
        this.btnLoading = false;
        this.updateOverFlag = true;
      },
      // 保存按钮事件 old by link
      // saveRecordClickFn({ row, $index }) {
      //   console.log("row", row);
      //   console.log("row.data.witnessRecordDesc", row.data.witnessRecordDesc);
      //   // 判断为空
      //   if (!row.data.itemCodes.length) {
      //     this.$message({
      //       type: "error",
      //       message: "事项说明不能为空！",
      //       single: true,
      //     });
      //     return;
      //   }
      //   if (!row.data.witnessRecordDesc) {
      //     this.$message({
      //       type: "error",
      //       message: "见证记录不能为空！",
      //       single: true,
      //     });
      //     return;
      //   }
      //   if (row.newAdd) {
      //     // 复核-保存-调新增
      //     let itemCodes = row.data.itemCodes.map((item) => {
      //       return item;
      //       // return item[0];多选
      //     });
      //     this.$set(this.recordData[$index], "edit", false);
      //     // v-model="scope.row.data.itemCodes"
      //     // :options="scope.row.matterInstruction"
      //     let params = {
      //       itemCodes,
      //       recordId: row.data.recordId,
      //       recordSort: row.data.recordSort,
      //       itemStatus: row.data.itemStatus,
      //       witnessRecordDesc: row.data.witnessRecordDesc,
      //       witnessSubTaskId: this.currProjectData.witnessSubTaskId,
      //       witnessTaskId: this.currProjectData.witnessTaskId,
      //       source:
      //         this.$store.getters.username || localStorage.getItem("username"),
      //     };
      //     console.log("params", params);
      //     this.witnessRecordAddFn(params);
      //   } else {
      //     this.$set(
      //       this.recordData[$index].data,
      //       "itemName",
      //       findArrayFn(row.matterInstruction, row.data.itemCodes[0]).label
      //     );
      //     this.witnessRecordUpdateFn($index);
      //   }
      //   // 系统推送的复核、确认按钮删除
      //   this.updateOverFlag = true;
      // },
      // 取消按钮事件
      cancelRecordClickFn() {
        this.jzsxVisible = false;
        this.btnLoading = false;
        this.currentRowData = {};
        this.currentRowScope = {};
        // if (this.recordData[$index].newAdd) {
        //   // 删除新增行
        //   this.recordData.splice($index, 1);
        //   // 取消按钮禁用
        //   // this.recordSaveAndCheckBtnFn({row,$index}, false);
        //   // this.recordData[$index].pageOpers.forEach((item, index) => {
        //   //   if (item.code === "OPERATE_WITNESS_RECORD_CHECK") {
        //   //     this.recordData[$index].pageOpers[index].disabled = false;
        //   //   }
        //   //   if (item.code === "OPERATE_WITNESS_RECORD_SUBMIT") {
        //   //     this.recordData[$index].pageOpers[index].disabled = false;
        //   //   }
        //   // });
        // } else {
        //   console.log("row", row);
        //   // 还原记录
        //   this.$set(
        //     this.recordData[$index],
        //     "data",
        //     JSON.parse(JSON.stringify(row.oldData))
        //   );
        //   this.$set(this.recordData[$index], "edit", false);
        // }
        this.checkRecordId = ""; // 复核有用到
        this.updateOverFlag = true;
        // let o = this.hasRecordDataFn(row, "YES");
        // if (o.f) {
        //   // 按钮启用
        //   this.recordSaveAndCheckBtnFn(o, false);
        // }
        // let f = this.recordData.some((item) => {
        //   return item.edit;
        // });
        // if (!f) {
        //   // this.updateOverFlag = false;
        //   // clearInterval(this.setIntervalFlag);
        //   this.witnessRecordListFn();
        // }
      },
      // 确认
      submitRecordClickFn({ row }) {
        this.$confirm("确认见证记录, 是否继续?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            this.currentRowData = row.data;
            this.witnessRecordConfirmOneFn();
          })
          .catch(() => {
            this.$message({
              type: "info",
              message: "已取消"
            });
          });
      },
      itemCodesChangeFn(e) {
        console.log("e", e);
        console.log("matterInstruction", this.currentRowScope.matterInstruction);
        const obj = this.currentRowScope.matterInstruction.find((item) => item.value === e[0]);
        this.currentRowData.witnessRecordDesc = obj.record;
      },
      // 下拉change
      async rowStartusChangeFn({ row, $index }) {
        console.log("11111111111");
        console.log(row, $index);
        // row.data
        const p = {
          parentCode: this.currentRowData.parentItemCode,
          itemStatus: this.currentRowData.itemStatus
        };
        const data = await this.itemDictListFn(p);
        // this.currentRowData;
        // this.currentRowScope.
        // this.$set(this.recordData[$index].data, "itemCode", "");
        // this.$set(this.recordData[$index].data, "itemName", "");
        // this.$set(this.recordData[$index].data, "itemCodes", []);
        // this.$set(this.recordData[$index], "matterInstruction", data);
        this.currentRowData.itemCodesOld = JSON.parse(JSON.stringify(this.currentRowData.itemCodes));
        this.$set(this.currentRowData, "itemCode", "");
        this.$set(this.currentRowData, "itemName", "");
        this.$set(this.currentRowData, "itemCodes", []);
        this.$set(this.currentRowScope, "matterInstruction", data);
        this.$nextTick(() => {
          console.log("matterInstruction", this.currentRowScope.matterInstruction);
          const obj = this.currentRowScope.matterInstruction.find((item) => item.defaultItem === "DEFAULT");
          this.currentRowData.itemCodes = [obj.value];
          this.currentRowData.witnessRecordDesc = obj.record;
          // if (condition) {
          // }
        });
      },
      rowItemCodeChangeFn() {},
      hasRecordDataFn(row, isSystem = "NO") {
        // 判断手动先添加的，复核到编辑
        let i = null;
        let row2 = null;
        console.log("row.data.itemCode", row.data.itemCode);
        const f = this.recordData.some((item, index) => {
          i = index;
          // console.log("item.data.parentItemCode", item.data.parentItemCode);
          // console.log("item.data.isSystem", item.data.isSystem);
          row2 = item;
          return item.data.parentItemCode === row.data.parentItemCode && item.data.isSystem === isSystem;
        });
        console.log("f", f);
        return { f, row: row2, $index: i };
      },
      recordSaveAndCheckBtnFn({ row, $index }, disabled = false) {
        row.pageOpers.forEach((item, index) => {
          // 复核按钮状态
          if (item.code === "OPERATE_WITNESS_RECORD_CHECK") {
            this.$set(this.recordData[$index].pageOpers[index], "disabled", disabled);
          }
          if (item.code === "OPERATE_WITNESS_RECORD_SUBMIT") {
            this.$set(this.recordData[$index].pageOpers[index], "disabled", disabled);
          }
        });
      },
      // 复核
      async checkRecordClickFn({ row }) {
        // 按钮禁用
        // this.recordSaveAndCheckBtnFn({ row, $index }, true);
        this.checkRecordId = row.data.recordId;
        console.log("this.checkRecordId", this.checkRecordId);
        // 这里复核需要修改，
        // 有相同的记录（系统和人工），则编辑人工记录
        // 只有系统，走新增
        const o = this.hasRecordDataFn(row);
        if (o.f) {
          // this.checkRecordId ="";
          // this.$set(this.recordData[i], "edit", true);
          this.editRecordClickFn(o);
          return;
        }
        this.currentRowData = {
          recordId: row.data.recordId,
          recordSort: row.data.recordSort,
          itemCode: row.data.itemCode,
          itemCodes: [row.data.itemCode],
          itemName: row.data.itemName,
          parentItemCode: row.data.parentItemCode,
          parentItemName: row.data.parentItemName,
          // witnessRecordDesc: row.data.witnessRecordDesc,
          witnessRecordDesc: "",
          itemStatus: row.data.itemStatus
        };
        // 添加一行
        const p = {
          parentCode: row.data.parentItemCode,
          itemStatus: row.data.itemStatus
        };
        const data = await this.itemDictListFn(p);
        this.currentRowScope.matterInstruction = data;
        if (this.checkRecordId && row.data.witnessRecordDesc) {
          // 把见证记录的时间截取出来给产生时间
          const time = row.data.witnessRecordDesc.match(/^(\d{4}-\d{1,2}-\d{1,2} \d{1,2}:\d{1,2}:\d{1,2})/g, "");
          if (time) {
            this.$set(this.currentRowData, "occurrentTime", time[0]);
          }
        }
        console.log("currentRowData", this.currentRowData);
        this.jzsxVisible = true;
        // // 插入新行
        // this.recordData.splice($index, 0, {
        //   data: {
        //     recordId: row.data.recordId,
        //     recordSort: row.data.recordSort,
        //     itemCode: row.data.itemCode,
        //     itemCodes: [row.data.itemCode],
        //     itemName: row.data.itemName,
        //     parentItemCode: row.data.parentItemCode,
        //     parentItemName: row.data.parentItemName,
        //     witnessRecordDesc: "",
        //     itemStatus: row.data.itemStatus
        //   },
        //   matterInstruction: data,
        //   newAdd: true,
        //   edit: true,
        //   submit: true,
        //   pageOpers: [
        //     // {
        //     //   code: "OPERATE_WITNESS_RECORD_EDIT",
        //     //   title: "编辑见证记录",
        //     //   url: "",
        //     //   desc: "",
        //     // },
        //     // {
        //     //   code: "OPERATE_WITNESS_RECORD_DELETE",
        //     //   title: "删除见证记录",
        //     //   url: "",
        //     //   desc: "",
        //     // },
        //   ]
        // });
      },
      deleteRecordClickFn({ row, $index }) {
        // 删除提示
        this.deleteVisible = true;
        this.deleteRow = row;
        this.deleteIndex = $index;
        // this.witnessRecordDeleteFn(row, $index);
      },
      handleClick() {
        this.className = "";
        console.log("this.sideRecordActive", this.sideRecordActive);
        if (this.sideRecordActive === "first") {
          this.activities = [].concat(this.activitiesOld);
          this.pageQueryList.currentPage = 1;
          this.infoRecordQuerylistFn();
        } else {
          this.activities = this.activitiesOld.filter((item) => item.witnessStatus === "EXCEPTION");
          this.pageQueryList.currentPage = 1;
          this.infoRecordQuerylistFn("EXCEPTION");
        }
      },
      enterClickFn() {},
      updateClickFn() {},
      async initParentCodeFn() {
        const p = { parentCode: -1 };
        this.witnessMatterOptions;
        const arr = await this.itemDictListFn(p);
        this.witnessMatterOptions = this.refreshOptionsFn(arr);
      },
      // 刷新见证事项的状态
      refreshOptionsFn(arr) {
        return arr.map((item) => {
          const flag = this.recordDataAll.some(
            (recordItem) =>
              // console.log(recordItem.data.parentItemCode, item.value);
              recordItem.data.parentItemCode === item.value
          );
          if (flag) {
            item.disabled = true;
          }
          return item;
        });
      },
      async handleChange() {
        // 预警级别逻辑暂时注释
        // if (this.addform.matterStatus === "NORMAL_TYPE") {
        //   this.$refs.addform.validateField("status");
        // }
        this.addform.itemCodeList = [];
        console.log("this.addform.taskMatterCode", this.addform.taskMatterCode);
        if (this.addform.taskMatterCode.length > 0 && this.addform.taskMatterCode[0]) {
          // this.$refs["addform"].resetFields();
          const p = {
            parentCode: this.addform.taskMatterCode[0] || -1,
            itemStatus: this.addform.matterStatus
          };
          // if (p.parentCode !=== -1) {
          // p.itemStatus = this.addform.matterStatus;
          // }
          this.matterInstruction = await this.itemDictListFn(p);
          console.log("this.matterInstruction", this.matterInstruction);
          console.log("this.addform.itemCodeList", this.addform.itemCodeList);
          if (this.matterInstruction && this.matterInstruction[0]) {
            this.addform.itemCodeList = [this.matterInstruction[0].value];
          }
        }
      },
      handleErrorLevelChangeFn() {
        // this.$refs.addform.validateField("status");
      },
      allSubmitFn() {
        this.witnessRecordClicksFn();
      },
      // 加入任务
      addTaskFn() {
        this.addTaskVisible = true;
      },
      // 记录状态
      witnessDataStatusFn(val) {
        const array = this.TASKOBJ.witnessDataStatus;
        const obj = findArrayFn(array, val) || {};
        return obj.label;
      },
      warningLevelFn(level, start) {
        // recordExceStatusEnum
        const obj = {
          HEIGHT: "danger",
          MIDDLE: "warning",
          LOW: "info"
        };
        let type = "";
        if (start === "EXCEPTION_TYPE") {
          type = obj[level];
        }
        return type || "primary";
      },
      witnessStatusFn(level, start) {
        // recordExceStatusEnum
        const obj = {
          HEIGHT: "red",
          LOW: "yellow"
        };
        //  jtem.witnessStatus == 'EXCEPTION' && jtem.warningLevel == 'HEIGHT'
        //                           ? 'red'
        //                           : jtem.witnessStatus == 'EXCEPTION' && jtem.warningLevel == 'LOW'
        //                           ? 'yellow'
        //                           : 'heise'
        let type = "";
        if (start === "EXCEPTION") {
          type = obj[level];
        }
        return type || "heise";
      },
      witnessItemStatusFn(val) {
        const array = this.TASKOBJ.witnessItemStatus;
        const obj = findArrayFn(array, val) || {};
        return obj.label;
      },
      async projectClickFn(data, i) {
        console.log("projectClickFn", i);
        console.log("projectClickFn", data);
        // this.subtaskTimeDiffTotle = 0;
        this.currProjectData = data;
        this.topTaskData.forEach((item, index) => {
          if (i === index) {
            sessionStorage.setItem("witnessSubTaskId", item.witnessSubTaskId);
            this.id = item.witnessSubTaskId;
            // wei页签联动新增弹框调用子组件方法
            this.scrollView(this.id);
            if (this.addMattersVisible) {
              this.$refs.vWorkBenchAddMatters.childWorkList(this.id);
            }
            // --------------wei
            console.log("this.id", this.id);
            this.$set(this.topTaskData[index], "active", "active");
          } else {
            this.$set(this.topTaskData[index], "active", "");
          }
        });
        // 表单重置，放到checkRecordFn中
        await this.checkRecordFn(); // 选中
        // //新增事项
        // await this.witnessRecordListFn();
        // await this.infoRecordQuerylistFn();
        // await this.initFn();
      },
      // 初始化模块
      async moduleInitFn() {
        const p = { moduleName: "TASK" };
        try {
          const res = await moduleInit(p);
          if (res.success) {
            this.TASKOBJ = res.data;
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (err) {
          console.error(err);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      // 确认-记录
      async witnessRecordConfirmOneFn() {
        // recordId 见证记录主键id，修改依据
        const p = {
          // witnessSubTaskId: this.id,
          recordId: this.currentRowData.recordId
        };
        try {
          const res = await witnessRecordConfirmOne(p);
          if (res.success) {
            // this.pageObj.currentPage = 1; // 当前页数
            // this.witnessRecordListFn();
            this.$message({
              type: "success",
              message: res.message || "操作成功",
              single: true
            });
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (err) {
          console.error(err);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      // 全部确认-记录
      async witnessRecordClicksFn() {
        console.log("this.id", this.id);
        // recordId 见证记录主键id，修改依据
        const p = {
          witnessSubTaskId: this.id
        };
        try {
          const res = await witnessRecordClicks(p);
          if (res.success) {
            // this.pageObj.currentPage = 1; // 当前页数
            // this.witnessRecordListFn();
            this.$message({
              type: "success",
              message: res.message || "操作成功",
              single: true
            });
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (err) {
          console.error(err);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      openMediaFn(flag) {
        // 管理员，查看视频
        //  bidSectionCode, witnessLinkCode, projectCode, witnessStartTime
        const { witnessSubTaskId } = this.currProjectData;
        console.log("this.currProjectData", this.currProjectData);
        // let videoCreateTime = witnessStartTime.split(" ")[0];
        // let startTime = new Date(videoCreateTime + " 00:00:00").getTime();
        // let endTime = new Date(videoCreateTime + " 23:59:59").getTime();
        let str = new Date().getTime();
        // id用于定位高亮
        str += `&witnessSubTaskId=${witnessSubTaskId}`;
        // if (flag === "gly") {
        //   // str += `&witnessSubTaskId=${witnessSubTaskId}`;
        //   // str += `&startTime=${startTime}&endTime=${endTime}`;
        //   // } else {
        //   //   // activeArr[0] = this.$route.query.bidSectionCode;
        //   //   // activeArr[1] = this.$route.query.witnessLinkCode;
        //   //   // activeArr[2] = this.$route.query.projectCode;
        //   //   str += `&bidSectionCode=${bidSectionCode}&witnessLinkCode=${witnessLinkCode}&projectCode=${projectCode}`;
        // }
        console.log("flag", flag);
        console.log("str", str);
        window.open(`${process.env.VUE_APP_MEDIA}${str}`, "witness_media");
      },
      finishWitnessFn() {
        if (this.addMattersVisible) {
          this.$message({
            type: "error",
            message: "结束见证前，请提交关闭新增见证事项弹框",
            single: true
          });
          return;
        }
        if (this.currProjectData.witnessSubTaskStatusEnum !== "WITNESSING") {
          // 记录转态，恢复后弹出结束框
          this.finishWitnessBtnFlag = true;
          // 恢复见证，才能结束
          this.subtaskRecoverClick();
          return;
        }
        this.finishVisible = true;
      },
      // 更新选项卡的灯泡
      updateIsWarnFn() {
        const jylcType = this.topTaskActive;
        let flag = false;
        if (this.topTaskData.length) {
          flag = this.topTaskData.some((item) => item.isWarn);
        }
        console.log("this.topTaskYujingData", this.topTaskYujingData);
        this.$set(this.topTaskYujingData, jylcType, { isWarn: flag });
        // this.topTaskYujingData[jylcType].isWarn = flag;
      },
      //  结束见证row, index
      async subtaskFinishFn() {
        console.log("this.id", this.id);
        const p = {
          witnessSubTaskId: this.id
        };
        try {
          const res =  await GZAPI_EvaluationTime.subtaskFinish(p);
          if (res.success) {
            this.$message({
              type: "success",
              message: res.message || "操作成功",
              single: true
            });
            // 预警更新
            // this.updateIsWarnFn();
            let id = "";
            // 只有一条时，结束见证，记录后为空
            if (this.topTaskData.length === 1) {
              this.$set(this.topTaskYujingData, this.topTaskActive, { isWarn: false });
              // this.topTaskYujingData[this.topTaskActive].isWarn = false;
              this.attachment = [];
              // this.topTaskAllData[]
              this.$delete(this.topTaskAllData, this.topTaskActive);
            } else {
              this.topTaskAllData[this.topTaskActive].forEach((item, index) => {
                if (item.witnessSubTaskId === this.id) {
                  this.topTaskAllData[this.topTaskActive].splice(index, 1);
                }
              });
              id = this.topTaskAllData[this.topTaskActive][0].witnessSubTaskId;
            }
            // if (this.topTaskData.length === 0) {
            //   location.reload();
            // }
            this.addTaskSubmitFn(id);
            // this.initFn("ends");
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (err) {
          console.error(err);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      //  见证时长 - 暂停时长
      async subtaskTimeDiffFn() {
        console.log("this.id", this.id);
        this.subtaskTimeDiffTotle = 0;
        this.subtaskTimeDiffStopTotle = 0;
        if (!this.id) {
          return;
        }
        const p = {
          witnessSubTaskId: this.id
        };
        try {
          const res = await subtaskTimeDiff(p);
          console.log("subtaskTimeDiff", res);
          if (res.success) {
            this.subtaskTimeDiffTotle = res.data.totalTime || 1;
            this.subtaskTimeDiffStopTotle = res.data.stopTotalTime;
            if (this.currProjectData.witnessSubTaskStatusEnum === "WITNESS_STOP") {
              this.currProjectData.witnessEndTime = res.data.stopTime; // "2022-07-10 00:00:00";
            } else if (this.currProjectData.witnessSubTaskStatusEnum === "WITNESSING") {
              this.currProjectData.witnessEndTime = "";
            }
          } else {
            this.finishWitnessBtnFlag = false;
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (err) {
          this.finishWitnessBtnFlag = false;
          console.error(err);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      // 记录-删除
      async witnessRecordDeleteFn(row1, index1) {
        console.log(row1, index1);
        // recordId 见证记录主键id，修改依据
        // witnessRecordDesc 见证记录描述
        // itemStatus 见证事项状态（  NORMAL_TYPE("正常类型"),EXCEPTION_TYPE("异常类型") ）
        // itemCode 见证事项编码
        const row = this.deleteRow;
        const index = this.deleteIndex;
        const p = [row.data.recordId];
        try {
          const res = await witnessRecordDelete(p);
          if (res.success) {
            this.deleteVisible = false;
            // this.witnessRecordListFn(); //更新列表
            this.$delete(this.recordData, index);
            // 放出复核
            // this.recordData.forEach((item) => {
            //   console.log("item", item);
            //   if (row.data.recordId === item.recordId) {
            //   }
            // });
            this.$message({
              type: "success",
              message: res.message || "删除成功",
              single: true
            });
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (err) {
          console.error(err);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      // 保存-更新
      async witnessRecordUpdateFn(index) {
        // recordId 见证记录主键id，修改依据
        // witnessRecordDesc 见证记录描述
        // itemStatus 见证事项状态（  NORMAL_TYPE("正常类型"),EXCEPTION_TYPE("异常类型") ）
        // itemCode 见证事项编码
        const p = {
          recordId: this.currentRowData.recordId,
          witnessRecordDesc: this.currentRowData.witnessRecordDesc,
          occurrentTime: this.currentRowData.occurrentTime,
          itemStatus: this.currentRowData.itemStatus,
          warningLevel: "",
          itemCodes: [this.currentRowData.itemCode]
        };
        if (p.itemStatus === "EXCEPTION_TYPE") {
          p.warningLevel = "HEIGHT";
          // p.warningLevel = this.currentRowData.warningLevel;
          // if (Array.isArray(p.warningLevel)) {
          //   p.warningLevel = this.currentRowData.warningLevel[0];
          // }
        }
        if (this.checkRecordId) {
          p.checkRecordId = this.checkRecordId;
        }
        if (this.currentRowData.itemCodes) {
          p.itemCodes = this.currentRowData.itemCodes || [this.currentRowData.itemCode];
        }
        try {
          const res = await witnessRecordUpdate(p);
          if (res.success) {
            this.$set(this.recordData[index], "edit", false);
            this.$message({
              type: "success",
              message: res.message || "操作成功",
              single: true
            });
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (err) {
          console.error(err);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
        this.checkRecordId = "";
      },
      // 见证-全部信息
      async infoRecordQuerylistFn(EXCEPTION) {
        this.activities = [];
        // this.pageQueryList.pageSize = -1;
        const p = {
          // currentPage: this.pageQueryList.currentPage, // 当前页数
          // pageSize: this.pageQueryList.pageSize, // 每页条数
          // pageSize: -1, // 每页条数
          witnessSubTaskId: this.id,
          witnessStatus: EXCEPTION
        };
        this.activitiesNoDataFlag = true;
        if (!this.id) {
          return;
        }
        try {
          const res = await newInfoRecordQuerylist(p);
          if (res.success) {
            this.activitiesNoDataFlag = !res.data.length;
            // this.activitiesNoDataFlag = false;
            this.activities = res.data;
            // this.pageQueryList.total = res.data.pageBean.count;
            this.activitiesOld = [].concat(res.data);
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (err) {
          console.error(err);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      // 见证-预警信息
      async warnRecordQuerylistFn() {
        // witnessStatus: "EXCEPTION"
        // 后端接口合并
        await this.infoRecordQuerylistFn("EXCEPTION");
        // this.activities = [];
        // // this.pageQueryList.pageSize = -1;
        // let p = {
        //   currentPage: this.pageQueryList.currentPage, // 当前页数
        //   pageSize: this.pageQueryList.pageSize, // 每页条数
        //   // pageSize: -1, // 每页条数
        //   witnessSubTaskId: this.id
        // };
        // this.activitiesNoDataFlag = true;
        // if (!this.id) {
        //   return;
        // }
        // try {
        //   const res = await warnRecordList(p);
        //   if (res.success) {
        //     this.activitiesNoDataFlag = !res.data.length;
        //     this.activities = res.data;
        //     // this.pageQueryList.total = res.data.pageBean.count;
        //     this.activitiesOld = [].concat(res.data.data);
        //   } else {
        //     this.$message({
        //       type: "error",
        //       message: res.message || "获取数据失败，请稍后再试",
        //       single: true
        //     });
        //   }
        // } catch (err) {
        //   console.error(err);
        //   this.$message({
        //     type: "error",
        //     message: "获取数据失败，请稍后再试",
        //     single: true
        //   });
        // }
      },
      // 见证事项-列表
      async itemDictListFn(p = {}) {
        // let p = {
        //   parentCode: this.addform.taskMatterCode[0] || -1,
        // };
        // if (p.parentCode !== -1) {
        //   p.itemStatus = this.addform.matterStatus;
        // }
        if (!this.id) {
          this.navBlankPage('/Workbench')
          return [];
        }
        p.witnessSubTaskId = this.id;
        try {
          const res = await itemDictList(p);
          console.log("itemDictList", res);
          if (res.success) {
            return res.data.map((item) => ({
              label: item.itemName,
              value: item.itemCode,
              defaultItem: item.defaultItem,
              record: item.record
            }));
          }
          this.$message({
            type: "error",
            message: res.message || "获取数据失败，请稍后再试",
            single: true
          });
        } catch (err) {
          console.error(err);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      // 见证事项-提交
      submitRecordFn() {
        this.$refs.addform.validate((valid) => {
          if (valid) {
            this.submitLoading = true;
            this.witnessRecordAddFn();
          } else {
            console.log("error submit!!");
            return false;
          }
        });
      },
      // 见证事项-新增
      async witnessRecordAddFn(params) {
        //       dataStatus INVALID
        // 枚举值: INVALID,VALID,TEMP,DELETE,ARCHIVE
        // itemCode 见证事项编码
        // itemStatus NORMAL_TYPE
        // 见证事项状态 枚举值: NORMAL_TYPE,EXCEPTION_TYPE
        // source 见证记录来源
        // witnessRecordDesc 见证记录描述
        // witnessRecordTime 记录时间
        // witnessSubTaskId 见证子任务id
        // witnessTaskId
        let p = {};
        if (params) {
          // 复核调新增
          p = params;
        } else {
          const itemCodes = this.addform.itemCodeList.map((item) => item);
          p = {
            itemCodes,
            itemStatus: this.addform.matterStatus,
            witnessRecordDesc: this.addform.witnessRecordDesc,
            warningLevel: "",
            // 预警级别暂时写死 22-3-25
            // warningLevel: this.addform.warningLevel[0],
            attachmentList: this.addform.attachmentList.map((item) => item.attachId),
            witnessSubTaskId: this.currProjectData.witnessSubTaskId,
            witnessTaskId: this.currProjectData.witnessTaskId,
            source: this.$store.getters.username || localStorage.getItem("username")
          };
          if (this.matterStatus === "EXCEPTION_TYPE") {
            p.warningLevel = "HEIGHT";
            // p.warningLevel = this.addform.warningLevel[0];
          }
        }
        try {
          const res = await witnessRecordAdd(p);
          if (res.success) {
            // this.addform.itemCodeList = [];
            if (!params) {
              this.addform.witnessRecordDesc = "";
              this.addform.matterStatus = "NORMAL_TYPE";
              this.addform.warningLevel = "";
              this.addform.attachmentList = [];
              this.matterInstruction = [];
              this.$refs["addform"].resetFields();
              this.$refs["upload"].clearFiles();
              // this.pageObj.currentPage = 1; // 当前页数
            }
            // if (params) {
            // } else {
            // }
            // this.pageObj.pageSize, // 每页条数
            this.witnessRecordListFn(); // 更新列表 1、添加后刷新；2、复核保存后刷新
            this.$message({
              type: "success",
              message: res.message || "添加成功",
              single: true
            });
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (err) {
          console.error(err);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
        this.submitLoading = false;
      },
      // 招投开评定切换
      async stepsClickFn(tab) {
        this.currProjectData = {};
        console.log("tab", tab);
        // // 初始化 表单
        this.initFromFn();
        // let i = tab.index;
        // let key = this.topTaskKeys[i];
        const key = this.topTaskActive;
        console.log("key", key);
        if (this.topTaskAllData[key]) {
          // this.stepActive = i;
          // this.topTaskKeys[i];
          // 选中任务
          this.topTaskData = this.topTaskAllData[key];
          if (this.topTaskData.length) {
            this.id = this.topTaskData[0].witnessSubTaskId;
            sessionStorage.setItem("witnessSubTaskId", this.id);
          } else {
            this.id = "";
            sessionStorage.setItem("witnessSubTaskId", this.id);
          }
          await this.$router.replace({
            query: {
              id: this.id
              // type: this.id,
            }
          });
          // if (this.id && this.addMattersVisible===false) {
          //   // 选中项目
          //   await this.checkRecordFn();
          // }
          // } else {
          // wei页签联动新增弹框调用子组件方法
          if (this.id) {
            if (this.addMattersVisible === true) {
              this.nodeScrollView(tab.name, this.id);
            } else {
              this.scrollView(this.id);
            }
          }
          // ----------------wei
        }
      },
      // 管理员-查看任务
      async subtaskInfoFn() {
        const p = {
          witnessSubTaskId: this.id,
          witnessLinkCode: this.witnessLinkCode
        };
        const res = await subtaskInfo(p);
        console.log("res", res);
        if (res.success) {
          this.currProjectData = res.data;
          // this.subtaskTimeDiffTotle = null;
          // await this.subtaskTimeDiffFn();
          // 管理员监听
          setTimeout(() => {
            this.webSocketTaskFn([res.data]);
          }, 1500);
          // 侧边栏、和列表接口
          await this.witnessRecordListFn();
          await this.infoRecordQuerylistFn(); //
        }
      },
      async webSocketTaskFn(data) {
        await data.forEach((item) => {
          console.log("订阅witnessSubTaskId", item.witnessSubTaskId);
          // 订阅消息监听
          const url = `/ws/witness/info/${item.witnessSubTaskId}`;
          if (this.subscribedUrlArr.indexOf(url) === -1) {
            this.$websocket.dispatch("websocket_subscribe", `/ws/witness/info/${item.witnessSubTaskId}`);
            this.subscribedUrlArr.push(url);
          }
        });
      },
      // 见证人员-任务列表 /gdw/witness/subtask/list
      async subtaskListPartFn(end) {
        console.log("end111", end);
        this.topTaskData = [];
        try {
          // let obj = {};
          const p = {
            // currentPage: this.pageObj.currentPage, // 当前页数
            pageSize: -1, // 每页条数
            // industryList, // 行业类型
            // industryTypeList, // 行业类型
            witnessSubTaskStatus: "WITNESSING" // 见证状态
            // witnessSubTaskId: this.id,
            // search: this.formSearch.keyWord, // 搜索
          };
          if (end === "end") {
            p.witnessSubTaskId = this.id;
          }
          const res = await GZAPI_EvaluationTime.subtaskListPart(p);
          console.log("subtaskListPart", res);
          if (res.success) {
            let str = "";
            this.TASKOBJ.taskWitnessLinkAll.forEach((item) => {
              if (res.data[item.value]) {
                // console.log("item", item.value);
                // console.log("res.data[item.value]", res.data[item.value]);
                const arr = res.data[item.value] || [];
                this.$set(this.topTaskAllData, item.value, arr);
                // this.topTaskAllData[item.value] = res.data[item.value] || [];
                // this.topTaskYujingData[item.value] = [];
                this.$set(this.topTaskYujingData, item.value, {});
                str = str || item.value;
                this.topTaskActive = this.topTaskActive || item.value;
              } else {
                this.$delete(this.topTaskAllData, item.value);
              }
            });
            await this.topTaskAllDataFn(); // 添加 jylcType 属性
            this.topTaskKeys = Object.keys(this.topTaskAllData);
            // console.log("this.topTaskKeys====", this.topTaskKeys);
            if (this.topTaskKeys.length === 0) {
              return;
            }
            // WebSocket 这里要改
            // process.env.
            // 刷新关闭websocket，会报错
            setTimeout(() => {
              this.topTaskKeys.forEach(async (item) => {
                console.log("item", item);
                await this.webSocketTaskFn(this.topTaskAllData[item]);
              });
            }, 1500);
            this.topTaskData = this.topTaskAllData[str];
            // 如果id不在列表中，给id重新赋值
            let flag = false;
            this.topTaskKeys.forEach((item) => {
              if (flag === false) {
                flag = this.topTaskAllData[item].some((itemB) => itemB.witnessSubTaskId === this.id);
              }
            });
            // console.log("flag======", flag);
            // console.log("this.topTaskData======", this.topTaskData);
            //
            if (!flag && this.topTaskData.length) {
              // [this.currProjectData] = this.topTaskData;
              this.id = this.topTaskData[0].witnessSubTaskId;
              sessionStorage.setItem("witnessSubTaskId", this.id);
            }
            // console.log("this.id===", this.id);
            this.$router.replace({
              query: {
                id: this.id
              }
            });
            // if (this.$route.path === "/Workbench") {
            // 选中任务
            await this.scrollView();
            await this.checkRecordFn();
            // }
          } else {
            this.$message({
              type: "error",
              message: "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (err) {
          console.error(err);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      topTaskAllDataFn() {
        const ok = Object.keys(this.topTaskAllData);
        const ov = Object.values(this.topTaskAllData);
        let arr = [];
        console.log("ok", ok);
        ok.forEach((item, index) => {
          ov[index].forEach((itemB) => {
            itemB.jylcType = item; // 改变源对象的属性
            if (itemB.isWarn) {
              this.$set(this.topTaskYujingData, item, { isWarn: true });
            }
          });
          arr = arr.concat(ov[index]);
        });
        console.log("ov", ov);
        console.log("ov", arr);
        this.topTaskAllArr = arr;
      },
      initFromFn() {
        // this.id=''
        this.currProjectData = {};
        this.subtaskTimeDiffTotle = 0;
        this.subtaskTimeDiffStopTotle = 0;
        this.recordData = [];
        this.activities = [];
        this.attachment = []; // 附件清空
        this.sideRecordActive = "first";
        // this.pageObj.currentPage = 1;
        // this.pageQueryList.currentPage = 1;
        this.submitLoading = false;
        // 初始化 表单
        this.addform.taskMatterCode = "";
        this.addform.matterStatus = "NORMAL_TYPE";
        this.addform.witnessRecordDesc = "";
        this.addform.itemCodeList = [];
        this.addform.warningLevel = "";
        this.witnessMatterOptions = [];
        this.matterInstruction = [];
        this.$refs["addform"] && this.$refs["addform"].resetFields();
      },
      // 选中任务
      async checkRecordFn(tab) {
        // console.log("ov", this.topTaskAllArr);
        // this.topTaskAllData[this.topTaskActive];
        this.initFromFn();
        const currTask = this.topTaskAllArr.filter((item) => item.witnessSubTaskId === this.id);
        console.log("ov11", this.topTaskAllArr);
        console.log("ov", this.topTaskData);
        // let currF = this.topTaskData.some((item) => {
        //   return item.witnessSubTaskId === this.id;
        // });
        if (currTask.length === 0) {
          this.id = "";
          sessionStorage.setItem("witnessSubTaskId", "");
          console.log("this.id", this.id);
          if (this.$route.query.id !== this.id) {
            this.$router.replace({
              query: {
                id: this.id
                // type: this.id,
              }
            });
          }
          return;
        }
        if (!tab) {
          this.topTaskActive = currTask[0].jylcType;
        }
        this.topTaskData = this.topTaskAllData[this.topTaskActive];
        // let flag = "";
        let i = 0;
        this.topTaskData.forEach((item, index) => {
          if (this.id === item.witnessSubTaskId) {
            i = index;
            // this.$set(this.topTaskData[index], "active", "active");
          } else {
            this.$set(this.topTaskData[index], "active", "");
          }
        });
        this.currProjectData = this.topTaskData[i] || {};
        // id 没有找到走这里
        this.$set(this.topTaskData[i], "active", "active");
        // this.$set(this.topTaskData[i], "danger", "");
        // this.$set(this.topTaskData, i{"isWarn": false});
        this.$set(this.topTaskData[i], "isWarn", false);
        // let jylcType = this.topTaskData[i].jylcType;
        // let flag = this.topTaskData.some((item) => {
        //   return item.isWarn;
        // });
        // this.topTaskYujingData[jylcType].isWarn = flag;
        // 更新选项卡的灯泡
        this.updateIsWarnFn();
        this.id = this.topTaskData[i].witnessSubTaskId;
        console.log("this.id", this.id);
        sessionStorage.setItem("witnessSubTaskId", this.id);
        // this.subtaskTimeDiffTotle = null;
        // await this.subtaskTimeDiffFn();
        if (this.$route.query.id !== this.id) {
          // url跳转
          this.$router.replace({
            query: {
              id: this.id,
              type: this.witnessLinkCode
            }
          });
        }
        console.log("=====================ov2", this.topTaskData);
        // if (this.id && this.id === this.$route.query.id) {
        //   this.topTaskData.forEach((item) => {
        //     console.log("订阅witnessSubTaskId", item.witnessSubTaskId);
        //     // 订阅消息监听
        //     let url = `/ws/witness/info/${item.witnessSubTaskId}`;
        //     if (this.subscribedUrlArr.indexOf(url) === -1) {
        //       this.$websocket.dispatch(
        //         "websocket_subscribe",
        //         `/ws/witness/info/${item.witnessSubTaskId}`
        //       );
        //       this.subscribedUrlArr.push(url);
        //     }
        //   });
        // } else {
        // }
        // 侧边栏、和列表接口
        console.log("=====================ov2", this.topTaskData);
        await this.witnessRecordListFn();
        console.log("=====================44");
        await this.infoRecordQuerylistFn(); //
      },
      // 可操作子任务列表
      async subtaskListOwnerFn() {
        try {
          const res = await subtaskListOwner();
          if (res.success) {
            this.topTaskData = res.data.data;
            if (!this.topTaskData.length) {
              return;
            }
            console.log(
              "sssss",
              res.data.data.some((item) => {
                console.log(item.witnessSubTaskId, this.id);
                return item.witnessSubTaskId === this.id;
              })
            );
            if (res.data.data.some((item) => item.witnessSubTaskId === this.id)) {
              // this.id = this.$route.query.id || this.id;
              [this.currProjectData] = res.data.data.filter((item, index) => {
                console.log("this.id", this.id);
                console.log("item.witnessSubTaskId", item.witnessSubTaskId);
                if (this.id === item.witnessSubTaskId) {
                  console.log("index", index);
                  this.$set(this.topTaskData[index], "active", "active");
                }
                return this.id === item.witnessSubTaskId;
              });
            } else {
              // if (this.topTaskData.length) {
              this.currProjectData = res.data.data[0] || {};
              this.$set(this.topTaskData[0], "active", "active");
              this.id = this.topTaskData[0].witnessSubTaskId;
              // }
            }
            console.log("currProjectData", this.currProjectData);
            console.log("this.id", this.id);
            if (this.id && this.id !== this.$route.query.id) {
              // url跳转
              this.$router.replace({
                query: {
                  id: this.id
                }
              });
            }
          } else {
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (err) {
          console.error(err);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      // 见证和交易数据关联
      associatedClickFn(row) {
        this.witnessStatus = "";
        this.className = "";
        const code = row.row.data;
        if (code.isSystem === "YES") {
          this.activities.map((item) => {
            if (code.parentItemCode === item.parentItemCode) {
              this.className = item.parentItemCode;
              document.getElementById(code.parentItemCode)?.scrollIntoView();
            }
          });
        }
      },
      matterKeyWordFn() {
        // this.recordData = this.recordDataOld.filter((item) => {
        //   return (
        //     item.data.parentItemName &&
        //     item.data.parentItemName.indexOf(this.matterKeyWord) > -1
        //   );
        // });
        // this.pageObj.currentPage = 1; // 当前页数
        this.witnessRecordListFn();
      },
      indexFn(index) {
        return index + 1 + (this.pageObj.currentPage - 1) * this.pageObj.pageSize;
      },
      // 见证记录-所有-添加时的禁用属性
      async witnessRecordListAllFn() {
        if (!this.id) {
          return;
        }
        const p = {
          witnessSubTaskId: this.id
        };
        this.recordDataAll = [];
        try {
          const res = await witnessRecordList(p);
          if (res.success) {
            this.recordDataAll = res.data.result;
          }
        } catch (error) {
          console.error(error);
        }
      },
      // 见证记录
      async witnessRecordListFn() {
        this.loading = true;
        if (this.recordListFlag) {
          return;
        }
        this.recordListFlag = setTimeout(() => {
          clearTimeout(this.recordListFlag);
          this.recordListFlag = null;
        }, 300);
        this.recordData = [];
        this.checkRecordId = "";
        this.pageObj.pageSize = -1;
        const p = {
          currentPage: this.pageObj.currentPage, // 当前页数
          pageSize: this.pageObj.pageSize, // 每页条数
          // pageSize: -1, // 每页条数
          witnessSubTaskId: this.id
        };
        if (this.matterKeyWord) {
          p.itemName = this.matterKeyWord;
        }
        if (!this.id) {
          return;
        }
        try {
          this.subtaskTimeDiffFn();
          const res = await witnessRecordList(p);
          this.getAttachmentListFn();
          if (res.success) {
            if (res.data.data.length === 0 && this.pageObj.currentPage !== 1) {
              console.log("见证记录重复");
              // this.pageObj.currentPage = 1;
              this.$nextTick(() => {
                this.witnessRecordListFn();
              });
              return;
            }
            this.pageObj.total = res.data.pageBean.count;
            this.recordDataOld = res.data.result;
            if (!this.managerFlag) {
              this.recordData = res.data.result;
            } else {
              this.recordData = res.data.result.map((item) => {
                item.pageOpers = [];
                return item;
              });
            }
            if (p.pageSize === -1) {
              // 拉取所有见证记录，用于添加时的禁用属性
              await this.witnessRecordListAllFn();
              await this.initParentCodeFn(); //
            }
            this.loading = false;
          } else {
            this.loading = false;
            this.$message({
              type: "error",
              message: res.message || "获取数据失败，请稍后再试",
              single: true
            });
          }
        } catch (error) {
          this.loading = false;
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      async getAttachmentListFn() {
        try {
          if (!this.id) {
            return;
          }
          const p = {
            witnessSubTaskId: this.id,
            pageSize: -1
          };
          const res = await getAttachmentList(p);
          if (res.success) {
            //
            // Object.hasOwnProperty(res,'data')
            this.attachment = res.data ? res.data.data : res.data;
          }
        } catch (error) {
          console.error(error);
          this.$message({
            type: "error",
            message: "获取数据失败，请稍后再试",
            single: true
          });
        }
      },
      buildRecordStatusFn(warningLevel, type) {
        console.log(warningLevel, type);
        // if (!warningLevel || !type) {
        //   return "";
        // }
        // const statusObj = {
        //   color: {
        //     HEIGHT: "#E82F2F",
        //     MIDDLE: "#FC9306",
        //     LOW: "#EAB909"
        //   },
        //   "bg-color": {
        //     HEIGHT: "rgba(232, 47, 47, 0.1)",
        //     MIDDLE: "rgba(252, 147, 6, 0.1)",
        //     LOW: "rgba(233, 193, 46, 0.1)"
        //   },
        //   "border-color": {
        //     HEIGHT: "rgba(232, 47, 47, 0.4)",
        //     MIDDLE: "rgba(252, 147, 6, 0.3)",
        //     LOW: "rgba(234, 185, 9, 0.3)"
        //   }
        // };
        // return statusObj[type][warningLevel] || "";
      },
      //  限制上传图片格式
      beforeUploadImage(file) {
        console.log("file.szie", file.size);
        console.log("file.type", file.type);
        const isSize = file.size / 1024 / 1024; // 文件大小
        const fileSize = 5;
        if (isSize > fileSize) {
          this.uploadFlag = true;
          // this.$message.error(`上传图片大小不能超过${fileSize}MB!`);
          this.$msgbox({
            title: "提示",
            message: `文件大小不能超过${fileSize}MB，请重新上传。`,
            type: "warning"
          });
          return false;
        }
        return true;
      },
      // 文件相关
      beforeRemoveFn(file) {
        if (!this.uploadFlag) {
          return this.$confirm(`确定移除 ${file.name}？`, "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          });
        }
      },
      onRemoveFn(file) {
        for (const [index, item] of this.addform.attachmentList.entries()) {
          if (item.uid === file.uid) {
            this.addform.attachmentList.splice(index, 1);
            return;
          }
        }
      },
      async uploadFileFn(params) {
        try {
          const form = new FormData();
          form.append("file", params.file);
          const res = await uploadFile(form);
          if (res.success) {
            this.addform.attachmentList.push({
              ...params.file,
              attachId: res.data
            });
          }
        } catch (error) {
          console.error(error);
          this.$message({
            type: "error",
            message: "上传文件失败，请稍后再试",
            single: true
          });
        }
      },
      onUploadSuccessFn() {
        this.$message({
          type: "success",
          message: "上传文件成功!",
          single: true
        });
      },
      onUploadFailedFn() {
        this.$message({
          type: "error",
          message: "上传文件失败，请稍后再试",
          single: true
        });
      },
      handleClickAddFn() {
        document.getElementsByClassName("el-upload__input")[0].click();
      },
      downloadAttachFn(scope) {
        const downloadUrl =
          scope.row.isSystem === "NO"
            ? `${process.env.VUE_APP_API}/platform/attach/download?attachId=${scope.row.attachmentPlatformId}`
            : scope.row.attachmentUrl;
        // let name = scope.row.attachmentName;
        const downloadRes = async () => {
          const response = await fetch(downloadUrl); // 内容转变成blob地址
          const blob = await response.blob(); // 创建隐藏的可下载链接
          const objectUrl = window.URL.createObjectURL(blob);
          const a = document.createElement("a");
          a.href = objectUrl;
          a.download = `${scope.row.attachmentName}.${scope.row.attachmentType}`;
          a.click();
          a.remove();
        };
        downloadRes();
      },
      handleAttachView(scope) {
        if (scope.row.isSystem === "NO") {
          this.downloadAttachFn(scope);
        } else {
          window.open(scope.row.attachmentUrl);
        }
      },
      deleteAttachFn(scope) {
        try {
          this.$confirm("确定删除该条附件吗？", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning"
          })
            .then(async () => {
              const p = {
                attachmentPlatformId: scope.row.attachmentPlatformId
              };
              console.log("come in");
              const res = await deleteAttachment(p);
              console.log(res);
              if (res.success) {
                this.$message({
                  type: "success",
                  message: "删除成功"
                });
                this.witnessRecordListFn(); // 刷新列表
              }
            })
            .catch(() => {
              this.$message({
                type: "info",
                message: "已取消"
              });
            });
        } catch (err) {
          this.$message({
            type: "error",
            message: "删除失败，请稍后再试",
            single: true
          });
        }
      },
      // 截取页签时间
      TimeSettlement(time) {
        const T = time.replace(/-/g, "").slice(0, 14);
        return T;
      }
    }
  };
</script>
<style lang="scss" scoped>

.witness-collapse {
  width: calc(100% - 32px);
  overflow-x: auto;
}

.witness-collapse-body {
  height: 81px;
  padding: 10px 20px 10px;
  box-sizing: border-box;
  display: flex;
  color: #333333;

  & > div {
    cursor: pointer;
    flex: none;
  }
}

.product-item {
  position: relative;

  .product-item-card-an {
    position: absolute;
    top: 7px;
    right: 9px;
    width: 8px;
    height: 47px;
    background: rgba(210, 210, 210, 0.4);
    border-top: 1px solid #D2D2D2;
    border-right: 1px solid #D2D2D2;
    border-bottom: 1px solid #D2D2D2;
    box-sizing: border-box;
    border-radius: 0 10px 10px 0;
    font-size: 7px;
    line-height: 47px;
    font-weight: bold;
  }

  .product-item-card {
    width: 384px;
    height: 63px;
    padding-right: 16px;
    box-sizing: border-box;
    position: relative;
    margin-right: 17px;
    border-radius: 3px;
    border: 1px solid #D2D2D2;

    & > div {
      width: 100%;
      height: 63px;
      border: 1px solid #D2D2D2;
      border-radius: 3px;
      margin-top: -1px;
      margin-left: -1px;
      padding: 5px 10px;
      box-sizing: border-box;
      & > div{
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-size: 12px;
      }

      .product-item-card-popover{
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        font-size: 12px;
      }

    }
    &:after {
      content: "";
      display: block;
      position: absolute;
      top: -1px;
      right: 7px;
      width: 11px;
      height: 63px;
      border-top: 1px solid #D2D2D2;
      border-right: 1px solid #D2D2D2;
      border-bottom: 1px solid #D2D2D2;
      box-sizing: border-box;
      border-radius: 0 3px 3px 0;
    }

  }

  &:hover {
    .product-item-card {
      background: rgba(24, 144, 255, 0.1);
      border-color: rgba(24, 144, 255, 1);

      & > div {
        color: rgba(24, 144, 255, 1);
        border-color: rgba(24, 144, 255, 1);
      }

      &:after {
        border-color: rgba(24, 144, 255, 1);
      }
    }

    .product-item-card-an {
      background: #1890FF;
      color: #ffffff;
      border-color: #1890FF;
    }
  }
}


.product-item-ok {

  .product-item-card {
    border: none;
    background: rgba(24, 144, 255, 0.4);
    color: #ffffff;

    & > div {
      margin-top: 0;
      margin-left: 0;
      border: none;
      background: rgba(24, 144, 255, 1);
    }

    &:after {
      top: 0;
      border: none;
      background: rgba(24, 144, 255, 0.6);
    }


  }

  .product-item-card-an {
    background: #1890FF;
    color: #ffffff;
    border-color: #1890FF;
  }


  &:hover {
    .product-item-card {
      background: rgba(24, 144, 255, 0.4);

      & > div {
        color: #ffffff;
        border-color: rgba(24, 144, 255, 1);
      }

      &:after {
        background: rgba(24, 144, 255, 0.6);
      }
    }
  }
}

.product-item_stop{
  & > div{
    opacity: .6;
  }
  position: relative;
  &:after{
    content: "";
    display: block;
    width: 75px;
    height: 75px;
    background-image: url('../../assets/imgs/yinzhang.png');
    position: absolute;
    top: calc((100% - 75px) / 2);
    right: 40px;
    line-height: 26px;
    pointer-events: none;
    z-index: 100;
    background-size: 75px;
  }
}


.task-item {
  width: 383px;
  height: 63px;
  padding: 5px 10px;
  box-sizing: border-box;
  border: 1px solid #D2D2D2;
  background: rgba(24, 144, 255, 0.1);
  margin-left: -1px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;

  .task-item-text{
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 12px;
  }
  .task-item-lest-button {
    position: absolute;
    top: 7px;
    right: 0px;
    color: #333333;
    background: rgba(210, 210, 210, 0.4);
    border-top: 1px solid #D2D2D2;
    border-left: 1px solid #D2D2D2;
    border-bottom: 1px solid #D2D2D2;
    border-right: none;
    box-sizing: border-box;
    width: 8px;
    height: 47px;
    border-radius: 10px 0 0 10px;
    font-size: 7px;
    line-height: 47px;
    font-weight: bold;

    &:hover {
      background: #1890FF;
      color: #ffffff;
      border-color: #1890FF;
    }
  }

  &:hover {
    z-index: 1;
    background: rgba(24, 144, 255, 0.1);
    color: #1890FF;
    border: 1px solid #1890FF;
  }
}

.task-item-first {
  border-radius: 3px 0 0 3px;
}

.task-item-last {
  border-radius: 0 3px 3px 0;
  margin-right: 10px;
}

.task-item-ok {
  color: #ffffff;
  background: #1890FF;
  border-color: #1890FF;
  .task-item-lest-button {
    background: #ffffff;
  }


  &:hover {
    color: #ffffff;
    background: #1890FF;
    border-color: #1890FF;
    .task-item-lest-button {
      background: #cccccc;
    }
  }
}


.button-list {
  display: flex;
  flex-wrap: wrap;

  & > * {
    margin-left: 0;
    margin-right: 10px;
    margin-bottom: 10px;
  }
}


  .level-tag {
    min-width: 56px;
    text-align: center;
    height: 24px;
    line-height: 22px;
  }
  .Workbench .witness-main {
    padding: 10px;
  }
  .layout-wrapper {
    font-size: 14px;
    .el-scrollbar {
      overflow: inherit !important;
    }
    .main-side {
      display: flex;
      // overflow: auto;
      position: relative;
      margin-right: 10px;
      width: 534px;
      border-right: 1px solid $line;
      // flex-direction: row;
      &.sideFold {
        width: 0px;
        overflow: revert;
        .side-content {
          display: none;
        }
        .fold-btn {
          right: -10px;
          border-radius: 0 10px 10px 0;
        }
        .timeline-box,
        .el-tabs {
          display: none;
        }
      }
      .side-content {
        // height: 0;
        display: flex;
        flex: 1;
        flex-direction: column;
        width: 100%;
        // .side-tabs {
        //   // width: 100%;
        //   // height: 100%;
        //   // display: flex;
        //   // flex-direction: column;
        // }
      }
      ::v-deep.demo-scrollbar-list {
        overflow: auto !important;
      }
      .timeline-box {
        flex: 1;
        // height: 0;
        // overflow: auto;
        padding: 4px;
        .timeline-box-content {
          display: flex;
          flex: 1;
          justify-content: center;
        }
        .timeline-tag {
          font-size: 10px;
          transform: scale(0.8);
          border: 1px solid #d2d2d2;
          display: inline-block;
          padding: 0 2px;
          color: #777777;
        }
        .timeline-content {
          font-size: 12px;
          .timeline-ul {
            li {
              padding: 7px 0;
              border-bottom: 1px dashed #ccc;
            }
          }
        }
      }
      .fold-btn {
        position: absolute;
        top: 50%;
        right: 0px;
        width: 12px;
        height: 78px;
        margin-top: -39px;
        background: #e5e5e5;
        line-height: 78px;
        border-radius: 10px 0 0 10px;
        cursor: pointer;
      }
    }
    .header-btn-box {
      padding-bottom: 4px;
      border-bottom: 1px solid #d2d2d2;
      .layout-time {
        // margin-top: 10px;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        // flex-direction: row-reverse;
        height: 42px;
        background: #f6f6f6;
        // opacity: 0.7;
        border-radius: 4px;
        padding: 0 10px;
        .interval-line {
          width: 0px;
          height: 26px;
          opacity: 0.57;
          border: 1px solid;
          border-image: linear-gradient(
              180deg,
              rgba(200, 200, 200, 0),
              rgba(169, 169, 169, 1),
              rgba(161, 161, 161, 1),
              rgba(151, 151, 151, 0)
            )
            1 1;
          margin: 0 10px;
        }
      }
    }
  }
  .red {
    color: #e82f2f;
  }
  .orange {
    color: #fc9306;
  }
  .yellow {
    color: #eab909;
  }
  .heise {
    color: #333;
  }
  .blue {
    color: #1890ff;
    font-size: 14px;
    font-family: "SimHei";
    font-weight: 700;
    padding-top: 5px;
  }
  .infinite-list-item {
    ::v-deep .el-timeline-item__node--info {
      background-color: #ffff00 !important;
    }
    ::v-deep .el-timeline-item__wrapper {
      top: 0 !important;
    }
    ::v-deep .el-timeline-item__node {
      border: 2px solid #fff !important;
    }
    ::v-deep .el-timeline-item__tail {
      left: 6px !important;
    }
    ::v-deep .el-timeline-item__tail {
      padding: 5px 0;
      border-left: 2px solid #1890ff !important;
    }
  }
  .warning {
    width: 20px;
    height: 20px;
    display: inline-block;
    background: rgb(255, 133, 2);
    color: #fff;
    text-align: center;
    border-radius: 50%;
    margin-right: 5px;
    margin-bottom: 20px;
  }
  // 20220222 页面结构改造
  .k-header-box {
    // height: 109px;
    position: relative;
    .add-task-btn {
      position: absolute;
      right: 0;
      top: 0;
    }
    .top-box {
      margin-top: 0px;
      height: auto;
      // position: absolute;
      align-items: flex-start;
      background: #fff;
      .top-task-box {
        // background: #b1c0d1;
        // .el-button {
        //   display: none;
        // }
        position: static;
        box-shadow: none;
      }
    }
    // .top-box .top-task-box ul.task-list.topTaskVisible {
    //   height: auto;
    //   overflow-y: auto;
    // }
    .top-box .top-task-box ul.task-list {
      // height: auto;
      // min-height: 57px;
      // max-height: 300px;
      // flex-wrap: wrap;
      // overflow: hidden;
      li {
        margin-top: 4px;
        // margin-bottom: 8px;
        max-height: 62px;
        padding: 4px 8px;
        border: 1px solid $line;
        border-radius: 4px;
      }
    }
    // .top-box .top-task-box ul.task-list li.active {
    //   background: none;
    //   border: 1px solid $primary;
    //   color: $primary;
    // }
    // .top-box .top-task-box ul.task-list li.active:hover{
    // }
    .top-box .top-task-box ul.task-list li .check::before {
      // background: #f00;
      border-top: 22px solid #f00;
      color: #fff;
      font-size: 14px;
    }
    .top-box .top-task-box ul.task-list li .check i {
      top: 0;
      right: 3px;
      font-size: 16px;
    }
  }
  .k-manager-header {
    font-size: 14px;
    line-height: 24px;
    margin-right: 8px;
    display: flex;
    align-items: center;
    .task-status {
      margin-left: 8px;
      margin-right: 8px;
      position: relative;
      i {
        display: none;
      }
      i.danger {
        display: block;
        em {
          color: #ff4b53;
          position: absolute;
          width: 11px;
          height: 11px;
          border: none;
          background: #fff;
          font-size: 10px;
          line-height: 10px;
          border-radius: 50%;
          right: -1px;
          bottom: 0px;
        }
      }
      span {
        font-size: 18px;
        padding: 7px 8px 7px 6px;
        line-height: 26px;
      }
    }
    .right-flex {
      display: flex;
      flex-direction: column;
    }
    span {
      vertical-align: middle;
    }
    .project-title {
      flex: 1;
      font-size: 16px;
      display: inline-block;
      overflow: hidden; //超出的文本隐藏
      text-overflow: ellipsis; //溢出用省略号显示
      white-space: nowrap; //溢出不换行
      .short-title {
        width: 100%;
        max-width: 40em;
        display: inline-block;
        overflow: hidden; //超出的文本隐藏
        text-overflow: ellipsis; //溢出用省略号显示
        white-space: nowrap; //溢出不换行
      }
    }
    .k-info {
      display: flex;
      align-items: center;
      .item {
        display: inline-block;
        padding-right: 40px;
      }
      i {
        padding-right: 2px;
      }
    }
  }
  .top-box {
    width: 100%;
    height: 50px;
    z-index: 9;
    position: relative;
    border-bottom: 1px solid $line;
    display: flex;
    align-items: center;
    flex-flow: row nowrap;
    justify-content: space-between;
    flex-direction: row;
    // h2 {
    //   font-size: 14px;
    //   line-height: 24px;
    //   margin-right: 8px;
    //   display: flex;
    //   .task-status {
    //     margin-left: 4px;
    //   }
    //   span {
    //     vertical-align: middle;
    //   }
    //   .project-title {
    //     flex: 1;
    //     display: inline-block;
    //     overflow: hidden; //超出的文本隐藏
    //     text-overflow: ellipsis; //溢出用省略号显示
    //     white-space: nowrap; //溢出不换行
    //     .short-title {
    //       width: 100%;
    //       max-width: 40em;
    //       display: inline-block;
    //       overflow: hidden; //超出的文本隐藏
    //       text-overflow: ellipsis; //溢出用省略号显示
    //       white-space: nowrap; //溢出不换行
    //     }
    //   }
    // }
    .top-btns {
      display: flex;
      align-items: center;
      justify-content: space-between;
    }
    // 任务列表
    .top-task-box {
      position: absolute;
      bottom: -53px;
      width: 100%;
      left: 0;
      display: flex;
      align-items: center;
      background: #fff;
      box-shadow: 0px 3px 10px rgba($color: #000000, $alpha: 0.4);
      .visible-hide {
        visibility: hidden;
      }
      ul.task-list {
        height: 83px;
        margin-right: 10px;
        overflow: auto;
        display: flex;
        flex: 1;
        li {
          width: 325px;
          margin-right: 10px;
          padding: 0 12px;
          display: flex;
          align-items: center;
          position: relative;
          cursor: pointer;
          // justify-content: center;
          .check {
            // display: none;
            position: absolute;
            top: 0;
            right: 0px;
            width: 22px;
            height: 22px;
            color: #fff;
            &::before {
              position: absolute;
              top: 0;
              right: 0;
              content: "";
              height: 0;
              width: 0;
              overflow: hidden;
              font-size: 0;
              line-height: 0;
              border-top: 22px solid #1890ff;
              border-left: 22px solid transparent;
            }
            i {
              position: absolute;
              top: 1px;
              right: 2px;
              width: 10px;
              font-size: 10px;
              transform: scale(0.8);
            }
          }
          &.active {
            // background: #dbedff;
            background: #1890ff;
            color: #fff;
            .check {
              display: block;
            }
            &:hover {
              background: #1890ff;
              color: #fff;
            }
          }
          // &.active:hover {
          //   background: #dbedff;
          //   color: #555;
          // }
          &:hover {
            background: #f7fbff;
            color: #1890ff;
          }
          .task-status {
            // text-align: center;
            width: 24px;
            height: 24px;
            display: inline-block;
            position: relative;
            i {
              display: none;
            }
            i.danger {
              display: block;
              border-radius: 50%;
              position: absolute;
              top: 0;
              left: 0;
              width: 22px;
              height: 22px;
              border: 1px solid #ff4b53;
              em {
                color: #ff4b53;
                position: absolute;
                width: 11px;
                height: 11px;
                border: none;
                background: #fff;
                font-size: 10px;
                border-radius: 50%;
                right: -6px;
                bottom: 0px;
              }
            }
          }
          .info {
            flex: 1;
            padding-left: 8px;
            padding-right: 5px;
            line-height: 18px;
            padding: 4px;
            width: 325px;
            .text1,
            .text2 {
              width: 325px;
              display: inline-block;
              em {
                font-style: normal;
                vertical-align: middle;
                display: inline-block;
              }
              span {
                width: 275px;
                vertical-align: middle;
                display: inline-block;
                overflow: hidden; //超出的文本隐藏
                text-overflow: ellipsis; //溢出用省略号显示
                white-space: nowrap; //溢出不换行
              }
            }
            .text3 {
              width: 325px;
              display: inline-block;
              em {
                font-style: normal;
                vertical-align: middle;
                display: inline-block;
              }
              span {
                padding-right: 10px;
                width: 110px;
                vertical-align: middle;
                display: inline-block;
                overflow: hidden; //超出的文本隐藏
                text-overflow: ellipsis; //溢出用省略号显示
                white-space: nowrap; //溢出不换行
              }
            }
          }
        }
      }
    }
  }
  .ui-mt {
    font-size: 14px;
    font-family: "SimHei";
    font-weight: bold;
  }
  .dialog-footer {
    text-align: right;
  }
  // .layout-crad {
  //   // height: 340px;
  // }
  .fold-card {
    height: 50px;
    overflow: hidden;
  }
  .record-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: inherit;
  }
  .record-list {
    flex: 1;
    overflow: initial;
    height: auto;
    // overflow: auto;
    // overflow: auto;
    // min-height: 200px;
    // .el-table {
    //   height: 100%;
    // }
    display: flex;
    flex-direction: column;
    .table-box {
      overflow: auto;
    }
  }
  .info-box {
    padding-left: 28px;
    position: relative;
    i {
      position: absolute;
      top: 0;
      left: 0;
      color: #e6ad00;
      font-size: 18px;
      vertical-align: top;
    }
  }
  .upload {
    ::v-deep .el-upload {
      display: none;
    }
    ::v-deep .el-upload-list {
      li:first-child {
        margin-top: 5px;
      }
    }
  }
</style>
<style lang="scss">
  .el-tag.el-tag--info.LOW {
    background-color: #fbf8eb;
    border-color: #f3e0b6;
    color: #d0a300;
  }
  .k-header-box {
    .el-tabs__content {
      height: 4px;
      font-size: 1px;
    }
  }
  .timeline-box {
    display: flex;
    height: calc(100% - 63px);
    box-sizing: border-box;
    .el-scrollbar {
      width: 517px;
    }
    .el-scrollbar__wrap {
      height: 100% !important;
    }
    .el-scrollbar__thumb {
      height: 0 !important;
    }
  }
  .dialog-confirm {
    .content-box {
      line-height: 24px;
      .el-icon-warning {
        color: $warning;
        padding-right: 10px;
        font-size: 24px;
        vertical-align: bottom;
      }
    }
  }
</style>
